I was trying to use redux in my react application but I see I can explicitly use redux in my application without using the react-redux library.
const redux = require('redux');
I am wondering then why do we even need react-redux library in our environment? Can someone help me with this?
React-redux is what makes your components rerender when Redux state that is being rendered by your component changes.
Of course you could also do
store.getState().foo.bar in your component, but then you would have to track manually when that state changes and rerender your component. Otherwise, it would always stay the same and never update.
If you instead use
useSelector(state => state.foo.bar), your component will always rerender when
state.foo.bar changes, so you don’t have to track that yourself.