728x90
What Is Cross-Component / App-Wide State?
- Local State
- State that belongs to a single component
- E.g. listening to user input in a input field; toggling a "show more" details field
- Should be managed component-internal with useState() / useReduce()
- Cross-Component State
- State that affects multiple components
- E.g. open/ closed state of a modal overlay
- Requires "props chains" / "prop drilling"
- App-Wide State
- State that affects the entire app (most/ all components)
- E.g. user authentication status
- Requires "props chains" / "prop drilling"
React Context - Potential Disadvantages
- Complex Setup / Management
- In more complex apps, managing React Context can lead to deeply nested JSX code and / or huge "Context Provider" components
- Performance
- React Context is not optimized for high-frequency state changes
- https://github.com/facebook/react/issues/14110#issuecomment-448074060
What is "Redux"?
A state manament system for cross-component or app-wide state
Core Redux Concepts
- Redux is all about having one Central Data(State) Store
728x90
'Study Note > React' 카테고리의 다른 글
Error #self.processResponse is not a function (0) | 2023.02.02 |
---|---|
Next.js #Image src - External CDN image is not visible (0) | 2022.10.06 |
React #Building Custom Hooks (0) | 2022.09.24 |
React #Rules of Hooks (0) | 2022.09.24 |
React #Understanding useReducer() (0) | 2022.09.24 |
댓글