Skip to content

전역스테이트(useReducer + ContextAPI) - 불필요한 리렌더링 #105

@ez1n

Description

@ez1n

useReducer와 ContextAPI를 사용하여 feed state를 다른 state와 전역으로 관리하고 피드를 작성할떄,
전체 state가 복사되어 불필요한 전체 리렌더링이 발생

이 때 문제는 피드 목록이 많아지는 경우 글쓰기가 느려지는 현상이 나타나는 것이었음

스크린샷_20221113_110921

스크린샷_20221113_110925

위 사진처럼 store와 Provider를 각각 정의하여 export한 후

스크린샷_20221113_110906

이렇게 따로 최상위 컴포넌트(App)를 감싸주면 해결할 수 있음

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions