Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Attempted import error: 'useDispatch' is not exported from 'react-redux'

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));
like image 505
Maciej Kitowski Avatar asked Jun 10 '19 14:06

Maciej Kitowski


3 Answers

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

like image 75
Murli Prajapati Avatar answered Nov 04 '22 02:11

Murli Prajapati


I just forget to give the curly braces over {useDispatch} and that's why I was facing this error!

like image 4
priota Avatar answered Nov 04 '22 01:11

priota


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.

like image 1
Will Jenkins Avatar answered Nov 04 '22 03:11

Will Jenkins