๐Ÿ“Day(49) 75์ผ์ฐจ WE_MOTIVATION_DIARY

8778 ๋‹จ์–ด MOTIVATION_DIARYMOTIVATION_DIARY

- ํ”„๋กœ์ ํŠธ ์ง„ํ–‰ํ˜„ํ™ฉ

  • ์ปดํฌ๋„ŒํŠธ ์นด๋“œ ๋ณ„๋กœ ํ•ด๋‹น ๋””ํ…Œ์ผ ์ด๋ฏธ์ง€ ๋ฐ›์•„์„œ ๋ณด์—ฌ์ฃผ๋Š” ๊ธฐ๋Šฅ ๊ตฌํ˜„
  • ์ƒ๋‹จ์œผ๋กœ ์˜ฌ๋ผ๊ฐ€๋Š” gototop ๋ฒ„ํŠผ๊ณผ ํ…์ŠคํŠธ ํ•˜์ด๋ผ์ดํŠธ ๊ธฐ๋Šฅ ์ถ”๊ฐ€

- TODAY I LEARN ERROR ๐Ÿฆ 

  • map์„ ๋Œ๋ฆฐ ์ปดํฌ๋„ŒํŠธ์— ๋‹ค๋ฅธ ์ด๋ฏธ์ง€, ๋ฐ์ดํ„ฐ๋ฅผ ๋ฐ›์•„์„œ ๋ฟŒ๋ ค์ค˜์•ผํ•˜๋Š”๋ฐ ๊ฐ™์€ ์ด๋ฏธ์ง€๋งŒ ๋‚˜์˜ค๋Š” ๋ฌธ์ œ์— ๋Œ€ํ•œ ๋ฌธ์ œ์ ์„ map์˜ ๊ตฌ์กฐ์—์„œ ๋ฐœ๊ฒฌํ•˜์˜€๋‹ค.
  • ํ˜„์žฌ fetch์—์„œ ๋ฐ›์€ ๋ฐ์ดํ„ฐ๋ฅผ map์„ 2๋ฒˆ ๋Œ๋ฆฌ๋‹ค ๋ณด๋‹ˆ div ์•ˆ์— img๊ฐ€ ๋“ค์–ด๊ฐ€๋ฒ„๋ฆฌ๋Š” ๋ฌธ์ œ๋„ ๋ฐœ์ƒํ•œ๋‹ค๋Š” ์ ๊นŒ์ง€
<script>
{productDetailImg.map(data => {
            const { detailImg } = data;
            return (
              <div>
                {detailImg.map(data => {
                  return (
                    <img
                      className='productDetailImage'
                      key={data.detail_id}
                      alt={data.name}
                      src={data.img}
                      onMouseOver={changeDetailProductImage}
                      onMouseLeave={this.hoverOut}
                    />
                  );
                })}
              </div>
            );
          })}
  </script>  

- HOW TO FIX MY ERROR ๐Ÿ’Š

  • ERROR๋ฅผ ํ•ด๊ฒฐํ•œ KEYWORD ๐Ÿ”‘
  • map์„ ์ด ๋‘๋ฒˆ, ๋ฉ”์ธ ์ด๋ฏธ์ง€(div)์— ํ•œ ๋ฒˆ, ๋””ํ…Œ์ผ ์ปดํฌ๋„ŒํŠธ์— ํ•œ ๋ฒˆ ๋”ฐ๋กœ ํ•ด์คŒ์œผ๋กœ์„œ ๋ฐ์ดํ„ฐ๋ฅผ ๋”ฐ๋กœ๋”ฐ๋กœ ๋ฐ›์•„์˜ฌ ์ˆ˜ ์žˆ์—ˆ๋‹ค.
  • img๊ฐ€ ์•„๋‹Œ div์˜ backgroundImage ์†์„ฑ์„ ํ†ตํ•ด์„œ ๋ฐฐ๊ฒฝ ์‚ฌ์ด์ฆˆ, ๋ฐ˜๋ณต, ์œ„์น˜ ์†์„ฑ๋„ ์คŒ์œผ๋กœ์„œ ๋ฐ›์•„์˜จ ์ด๋ฏธ์ง€ src๋ฅผ ๋ฐ”๋กœ ๋„ฃ์–ด ์ค„ ์ˆ˜ ์žˆ์–ด๋‹ค.
<script>
<div className='detailImgWrapper'>
            <div
              className='productMainImg'
              style={{
                backgroundImage: `url(${productImg})`,
                backgroundRepeat: 'no-repeat',
                backgroundSize: 'contain',
                backgroundPosition: 'center',
              }}
</div>
            {productDetailImg.map(product => {
              return (
                <ProductDetailCard
                  key={product.detail_id}
                  detailImage={mainImage}
                  name={product.name}
                />
              );
            })}
       </div>
</script>

- ๋ชจ๋ฅด๋Š” ์ 

  • ๋ฌดํ•œ ์Šคํฌ๋กค์„ ๊ณต๋ถ€ํ•˜๊ธฐ ์ „ ์Šคํฌ๋กค ๊ด€๋ จํ•œ mdn ๊ณต์‹๋ฌธ์„œ๋ฅผ ์ฝ์–ด๋ณด๋ฉด window.scrollTop๊ณผ ๊ฐ™์€ ์†์„ฑ ๊ทธ๋ฆฌ๊ณ  ํšจ๊ณผ์— ๋Œ€ํ•ด์„œ

- ๋ฐฐ์šด์ 

๋ฆฌ์•กํŠธ์—์„œ ์Šคํฌ๋กค ์ด๋ฒคํŠธ๋ฅผ ํ†ตํ•ด ๋ฌดํ•œ ์Šคํฌ๋กค์„ ๊ตฌํ˜„ํ•  ์ˆ˜ ์žˆ๋Š” ๋ฐฉ๋ฒ•์œผ๋กœ๋Š” 1> onScroll ์ด๋ฒคํŠธ 2> Intersection Observer API๊ฐ€ ์žˆ๋‹ค๊ณ ํ•œ๋‹ค. ๋‚ด์ผ์€ ์ด ๋‘๊ฐ€์ง€์— ๋Œ€ํ•ด ๊ณต๋ถ€ํ•œ ๋’ค ๊ธฐ๋Šฅ ๊ตฌํ˜„์„ ๋งˆ๋ฌด๋ฆฌํ•ด์•ผ๊ฒ ๋‹ค.

- ์ž˜ํ•œ ์ ๊ณผ ๊ฐœ์„ ํ•  ์ 

  • ์งง์ง€๋งŒ ์ž๊ธฐ ์ „์— ๋‹ค์ด์–ด๋ฆฌ๋ฅผ ์“ฐ๊ณ  ์ž”๊ฑฐ! ์ž˜ํ–ˆ๋”ฐ!
  • ํ˜„์žฌ ์‹œ๊ฐ 2์‹œ 20๋ถ„ ์˜ค๋Š˜์€ ์ผ์ฐ์ž๊ณ ์ž ํ–ˆ์œผ๋‚˜ ์ €๋… ์‹œ๊ฐ„์„ ์‹œ์—„์‹œ์—„ํ•˜๋ฉด์„œ ํ–ˆ๋˜๊ฑฐ๊ฐ™๋‹ค. ๋‚ด์ผ์€ ์ง‘์—๋งŒ ์žˆ์ง€๋ง๊ณ  ์นดํŽ˜๋‚˜ ๊ฐ€๋ณด๋˜์ง€ํ•ด์•ผ๊ฒ ๋‹ค. ์šฐ์„  ์ค‘์š”ํ•œ ๊ฑด ์ผ์ฐ ์ผ์–ด๋‚˜์•ผ๋Š”๊ฑฐ~

- ๋ชฉํ‘œ์™€ ๋งˆ๊ฐ๊ธฐํ•œ: 2021-10-06

  • ๋ฆฌ์ŠคํŠธ ํŽ˜์ด์ง€ ํ˜ธ๋ฒ„ ๊ธฐ๋Šฅ ๊ตฌํ˜„ ๊ฐ„๋‹จํ•˜๊ฒŒ๋ผ๋„ ๋งˆ์น˜๊ธฐ => ํ•œ ์ปดํฌ๋„ŒํŠธ๋งŒ ์‹คํ˜„
  • ๋ฐฑ์—”๋“œ ๋ธ”๋กœ๊น… ๋งˆ์น˜๊ธฐ => ๊ณ„์† ๋ฏธ๋ฃจ๋Š” ์ค‘ ING
  • ํšŒ๊ณ ๋ก ์ ๊ณ ์ž๊ธฐ => ์ปดํ”Œ๋ฆฌํŠธ!
    A. ๋‚จ์€ ๊ธฐ๋Šฅ, ๋ฌดํ•œ ์Šคํฌ๋กค ๊ด€๋ จ ๊ณต๋ถ€ํ•ด์„œ ๊ตฌํ˜„ํ•ด๋ณด๊ธฐ
    B. ์–ด์ œ ๋…ธ์…˜์— ๋‚˜์˜จ ํ‚ค์›Œ๋“œ ์•„์นจ์— ๊ฐ„๋‹จํ•˜๊ฒŒ๋ผ๋„ ๊ณต๋ถ€ํ•˜๊ธฐ
    C. ํ”„๋ก ํŠธ ๋งˆ์นœ ๋’ค ๋ฆฌํŒฉํ† ๋ง ์ „ peerReview๋ฐ›๊ธฐ
    D. ๋ฐฑ์—”๋“œ ๊ฐ•์˜ 2๊ฐœ ๋ณด๊ณ  ์ฝ”๋“œ ์ณ์„œ ๊ฐ ์žƒ์ง€ ์•Š๊ธฐ.

์ข‹์€ ์›นํŽ˜์ด์ง€ ์ฆ๊ฒจ์ฐพ๊ธฐ