aliezaheer
aliezaheer

Reputation: 71

React: Can't import createstore from redux

I'm not able to import the createStore from the react-redux. It's get canceled as you can see in the image below.

enter image description here

enter image description here

Upvotes: 1

Views: 11804

Answers (2)

Omar Saade
Omar Saade

Reputation: 595

Yes, If you try to import createStore you will see this message:

@deprecated

We recommend using the configureStore method of the @reduxjs/toolkit package, which replaces createStore.

Redux Toolkit is our recommended approach for writing Redux logic today, including store setup, reducers, data fetching, and more.

For more details, please read this Redux docs page: https://redux.js.org/introduction/why-rtk-is-redux-today

configureStore from Redux Toolkit is an improved version of createStore that simplifies setup and helps avoid common bugs.

You should not be using the redux core package by itself today, except for learning purposes. The createStore method from the core redux package will not be removed, but we encourage all users to migrate to using Redux Toolkit for all Redux code.

If you want to use createStore without this visual deprecation warning, use the legacy_createStore import instead:

import { legacy_createStore as createStore} from 'redux'

Upvotes: 3

bouffelec
bouffelec

Reputation: 173

It is getting imported. It is just deprecated. It can still be imported in the future with legacy_createStore. They recommend to use redux-toolkit.

Read about it in the release notes: https://github.com/reduxjs/redux/releases/tag/v4.2.0

Upvotes: 6

Related Questions