Lars Mohammed
Lars Mohammed

Reputation: 117

How to access store instance within react component

I'm trying to differentiate different redux state changes and saw this github solution: Redux-watch In order to the watch function you're supposed to provide the redux store which can't figure out how to do. I'm passing the store down to this component through a provider for reference.

Upvotes: 0

Views: 94

Answers (1)

markerikson
markerikson

Reputation: 67577

If you need access to the store state in a component, you should be using the useSelector hook or the connect higher-order component. Don't try to set up store subscriptions yourself in components - React-Redux does that for you already.

Upvotes: 3

Related Questions