Answer the question
In order to leave comments, you need to log in
Why do we need react-redux if the data can be obtained through, for example, const {name}=store.getState()?
What is the point of the react-redux library, if all the data can be obtained through store.getState(), and we call the rerender through store.subscribe(render) (we render in index.js and there we just render the entire app) as a result, everything works what is the point of this library then? (well, we also update the store by store.dispatch(action)) as a result, we don’t need a Provider or connect, we already communicate in the store and dispatch actions to it directly without additional bindings through props. (just less code in total)
Answer the question
In order to leave comments, you need to log in
In very large projects, it is unacceptable to redraw the entire DOM tree on each store change (which will happen with store.subscribe(render)). Provider allows you to connect a specific store to a specific component, which is not possible by simply importing a store from a file. Such a differentiation of SPA into separate features. connect()
allows you to connect only selected actions and data in a specific component. This way, the dependencies of the component are more clearly visible and the subscription to changes occurs correctly. In this case, the component will be redrawn only when the data that is connected to it changes, and not the entire store.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question