setTimeout๋ฆฌ์•กํŠธ

ยท React
์ปดํฌ๋„ŒํŠธ๊ฐ€ ์ƒ์„ฑ๋˜๊ฑฐ๋‚˜ ์—…๋ฐ์ดํŠธ๋˜๊ฑฐ๋‚˜ ์‚ญ์ œ๋ ๋•Œ, ์ปดํฌ๋„ŒํŠธ์— ์–ด๋–ค ํšจ๊ณผ๋ฅผ ์ฃผ๋Š” ํ•จ์ˆ˜ useEffect()๋ฅผ ๋ฐฐ์›Œ๋ณผ ๊ฑฐ์˜ˆ์š” use์–ด์ฉŒ๊ตฌ๋กœ ์‹œ์ž‘ํ•˜๊ธฐ ๋•Œ๋ฌธ์— ์ด๊ฑธ lifecycle hook ์ด๋ผ๊ณ ๋„ ๋ถ€๋ฆ…๋‹ˆ๋‹ค ์š”์ฆ˜ React์—์„œ Lifecycle hook ์“ฐ๋Š” ๋ฒ• import {useState, useEffect} from 'react'; function Detail(){ useEffect(()=>{ //์—ฌ๊ธฐ์ ์€ ์ฝ”๋“œ๋Š” ์ปดํฌ๋„ŒํŠธ ๋กœ๋“œ & ์—…๋ฐ์ดํŠธ ๋งˆ๋‹ค ์‹คํ–‰๋จ console.log('์•ˆ๋…•') }); return (์ƒ๋žต) } ์ƒ๋‹จ์— useEffect import ํ•ด์˜ค๊ณ , useEffect ์— ์ฝœ๋ฐฑํ•จ์ˆ˜(ํŒŒ๋ผ๋ฏธํ„ฐ๋ฅผ ํ•จ์ˆ˜๋กœ ๋ฐ›๋Š”๊ฒƒ)๋ฅผ ์ ์–ด์ฃผ๋ฉด, {} ์•ˆ์— ์žˆ๋Š” ํ† ๋“œ๋ฅผ ์ปดํฌ๋„ŒํŠธ ๋กœ๋“œ(์ƒ์„ฑ) ๋˜๋Š” ์—…๋ฐ์ดํŠธ์‹œ ์‹คํ–‰ํ•ฉ๋‹ˆ๋‹ค useE..
becky(์ง€์€)
'setTimeout๋ฆฌ์•กํŠธ' ํƒœ๊ทธ์˜ ๊ธ€ ๋ชฉ๋ก