docs/troubleshooting.md
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!
You can also ask questions on Stack Overflow using the #redux tag.
In short,
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 props.addTodo() (if using connect + mapDispatch).If you have context issues,
<Provider>.If you’re using React for web, this usually means you have a duplicate React. Follow the linked instructions to fix this.
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:
// my.test.jsx
/**
* @jest-environment node
*/
Or by setting it globally:
// package.json
{
"name": "my-project",
"jest": {
"testEnvironment": "node"
}
}
See https://github.com/facebook/react/issues/14927#issuecomment-490426131