TIL ๐Ÿ‘ฉ๐Ÿปโ€๐Ÿ’ป

์ˆ˜ํˆด๋ฆฌ ์–‘ยท2021๋…„ 6์›” 28์ผ
0

TIL

๋ชฉ๋ก ๋ณด๊ธฐ
1/5

1. useEffect Hook

& side effect [React]

  • useEffect(() => {}, [])

    • ์ฒซ๋ฒˆ์งธ ์ธ์ž๋Š” ํ•จ์ˆ˜, side effect๋ฅผ ์ผ์œผํ‚ด
    • ๋‘๋ฒˆ์งธ ์ธ์ž๋Š” ์–ด๋–ค ๊ฐ’์˜ ๋ณ€๊ฒฝ์ด ์ผ์–ด๋‚  ๋•Œ๋ฅผ ์˜๋ฏธํ•˜๋Š” ์กฐ๊ฑด์„ ๋‹ด๊ณ  ์žˆ์Œ(๋ฐฐ์—ด)
  • ์ปดํฌ๋„ŒํŠธ ๋‚ด๋ถ€์—์„œ useEffect hook ์”€์œผ๋กœ์จ => causing side effect in a functional Component, and state&props ์ ‘๊ทผ ๊ฐ€๋Šฅ

  • effect๋ฅผ ์“ฐ๋Š” ๊ฒฝ์šฐ: requesting React to execute function that is passed as an argument everytime the Component renders.

    • useEffect runs after every render of the Component.
      *class component; initial & update both run after first render and after every update
  • ์ตœ์ƒ์œ„ ์ปดํฌ๋„ŒํŠธ์—์„œ๋งŒ hook์„ ํ˜ธ์ถœํ•ด์•ผํ•˜๋ฉฐ React ํ•จ์ˆ˜ ๋‚ด์—์„œ hook์„ ํ˜ธ์ถœํ•ด์•ผ ํ•จ

Conditionally run effects

Codevolution - React Hook Tutorial ์˜์ƒ 6๋ฒˆ~8๋ฒˆ

์ƒํƒœ ๋Œ์–ด์˜ฌ๋ฆฌ๊ธฐ(lifting state up)

: ํ•˜์œ„ ์ปดํฌ๋„ŒํŠธ์—์„œ์˜ ํด๋ฆญ ๋“ฑ์˜ ์ด๋ฒคํŠธ๊ฐ€ ์ƒ์œ„(๋ถ€๋ชจ) ์ปดํฌ๋„ŒํŠธ์˜ ์ƒํƒœ๋ฅผ ๋ฐ”๊พผ๋‹ค.
์ƒ์œ„ ์ปดํฌ๋„ŒํŠธ์˜ ์ƒํƒœ๋ฅผ ๋ณ€๊ฒฝํ•  ํ•จ์ˆ˜ ์ž์ฒด๋ฅผ (๋งˆ์น˜ ์ฝœ๋ฐฑ์ฒ˜๋Ÿผ) handler๋กœ ํ•˜์œ„ props๋กœ ์ „๋‹ฌ, ์ด ํ•จ์ˆ˜๋ฅผ ํ•˜์œ„ ์ปดํฌ๋„ŒํŠธ๊ฐ€ ์‹คํ–‰ํ•œ๋‹ค.


2. Algorithm

  • ์ฝ”๋”ฉํ…Œ์ŠคํŠธ๋ฌธ์ œ - ์ด์ง„ํƒ์ƒ‰(Binary Search) *์žฌ๊ท€๋กœ๋„ ๊ฐ€๋Šฅ(๊ตฌํ˜„ํ•ด๋ณด๊ธฐ)

  • big O ์‹œ๊ฐ„๋ณต์žก๋„ nomad coder

profile
developer; not kim but Young

0๊ฐœ์˜ ๋Œ“๊ธ€