I wonder which components are re-rendering when state on Redux changes. The whole "App" component or components that we use the value of the changed state
CodePudding user response:
It will rerender the component where you have used the redux store value, Either using useSelector
or mapStateToProps
you subscribe store.
If you have used redux store values in "App" then it will rerender whole app.
Redux is like react state but react state is limited to component and redux state can be accessed across components.
useSelector compares its results using strict === reference comparisons, so the component will re-render any time the selector result is a new reference! This means that if you create a new reference in your selector and return it, your component could re-render every time an action has been dispatched, even if the data really isn't different.
Reference: https://redux.js.org/tutorials/fundamentals/part-5-ui-react