The #redux channel of the Reactiflux Discord community is our official resource for all questions related to learning and using Redux. Reactiflux is a great place to hang out, ask questions, and learn - come join us!
My views aren’t updating!
- Reducers should never mutate state, they must return new objects, or React Redux won’t see the updates.
- Make sure you are actually dispatching actions. For example, if you have an action creator like
addTodo, just calling the imported
addTodo()function by itself won't do anything because it just returns an action, but does not dispatch it. You either need to call
dispatch(addTodo())(if using the hooks API) or
Could not find "store" in either the context or props
If you have context issues,
- Make sure you don’t have a duplicate instance of React on the page.
- Make sure you don't have multiple instances/copies of React Redux in your project.
- Make sure you didn’t forget to wrap your root or some other ancestor component in
- Make sure you’re running the latest versions of React and React Redux.
Invariant Violation: addComponentAsRefTo(...): Only a ReactOwner can have refs. This usually means that you’re trying to add a ref to a component that doesn’t have an owner
If you’re using React for web, this usually means you have a duplicate React. Follow the linked instructions to fix this.
I'm getting a warning about useLayoutEffect in my unit tests
ReactDOM emits this warning if
useLayoutEffect is used "on the server". React Redux tries to get around the issue by detecting whether it is running within a browser context. Jest, by default, defines enough of the browser environment that React Redux thinks it's running in a browser, causing these warnings.
You can prevent the warning by setting the
@jest-environment for a single test file:
* @jest-environment node
Or by setting it globally: