I am trying to update my store in redux via useDispatch method, but I am getting a message like that:
Attempted import error: 'useDispatch' is not exported from 'react-redux'.
I am using this method for call the action to update my store.
import { useDispatch } from 'react-redux';
import { loggedInAction } from './redux';
const userInfo = () => {
const dispatch = useDispatch();
const loggedIn = user => dispatch(loggedInAction(user));
Edit (Sept 15, 2019):
Install [email protected]
or react-redux@latest
Find latest version here: https://www.npmjs.com/package/react-redux?activeTab=versions
Install react-redux
version: 7.1.0-rc.1
or do npm install react-redux@next
I just forget to give the curly braces over {useDispatch} and that's why I was facing this error!
You need to use v7.1.0, current release candidate is v7.1.0-rc.1
See this page
Note: The hook APIs listed in this page are currently a release candidate! We encourage you to try them out in your applications and give feedback. We hope that the APIs are stable at this point, but be aware that there may still be changes before final release.
These hooks were first added in v7.1.0.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With