React style 객체로 넣으면

0
post-thumbnail

React로 웹만들때 귀찮다고 (특히 antd, bootstrap같은 css라이브러리 커스터마이징할때)

<div style={{ marginTop: 10 }}>

이렇게 style에 객체 넣어버리는데

객체끼리의 비교는 무조건 false 가 나온다.

이전 DOM이랑 비교하는 React 동작방식 특성상

쓸모없는 리렌더링이 일어난다.

해결방법 : useMemo, styled-components

1개의 댓글

comment-user-thumbnail
2022년 8월 22일

useMemo 좋더라구요!

답글 달기