[React] React.PureComponent(์„ฑ๋Šฅ ํ–ฅ์ƒ)
ยท
Frontend/React
PureComponent & memo Component์— state๋‚˜ props์— ๋ณ€ํ™”๊ฐ€ ์—†๋‹ค๋ฉด render ํ•จ์ˆ˜๊ฐ€ ํ˜ธ์ถœ๋˜์ง€ โŒ React.PureComponent React.PureComponent๋Š” React.Component์™€ ๋น„์Šทํ•˜๋‹ค. React.Component๋Š” shouldComponentUpdate()๋ฅผ ๊ตฌํ˜„ํ•˜์ง€ ์•Š์ง€๋งŒ, React.PureComponent๋Š” props์™€ state๋ฅผ ์ด์šฉํ•œ ์–•์€ ๋น„๊ต(๋ ˆํผ๋Ÿฐ์Šค๋งŒ ๋น„๊ตํ•ด์„œ ์•ˆ์— ๋ฐ์ดํ„ฐ๊ฐ€ ๋‹ฌ๋ผ์ ธ๋„ ๋™์ผํ•œ ์˜ค๋ธŒ์ ํŠธ)๋ฅผ ๊ตฌํ˜„ํ•œ๋‹ค๋Š” ์ฐจ์ด์ ๋งŒ์ด ์กด์žฌํ•œ๋‹ค. ์ฐธ์กฐ๊ฐ’์ด ๋™์ผํ•˜๋ฉด ์—…๋ฐ์ดํŠธ โŒ => ShouldComponentUpdate ํ•จ์ˆ˜๋Š” false๋ฅผ ๋ฆฌํ„ด React ์ปดํฌ๋„ŒํŠธ์˜ render() ํ•จ์ˆ˜๊ฐ€ ๋™์ผํ•œ props์™€ state์— ๋Œ€ํ•˜์—ฌ ๋™์ผํ•œ ๊ฒฐ๊ณผ๋ฅผ ๋ Œ..
_์„ฑํ˜ธ_
'PureComponent' ํƒœ๊ทธ์˜ ๊ธ€ ๋ชฉ๋ก