老师为什么create store 不能使用 会报错
后来我根据建议安装了 Redux Toolkit
但是还是不会使用 Redux Toolkit
@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'
@不推荐使用
我们推荐使用 @reduxjs/toolkit 包的 configureStore 方法,它取代了 createStore。
Redux Toolkit 是我们推荐的当今编写 Redux 逻辑的方法,包括存储设置、reducers、数据获取等。
有关更多详细信息,请阅读此 Redux 文档页面:https://redux.js.org/introduction/why-rtk-is-redux-today
Redux Toolkit 中的 configureStore 是 createStore 的改进版本,它简化了设置并有助于避免常见错误。
你今天不应该单独使用 redux 核心包,除非是为了学习目的。核心 redux 包中的 createStore 方法不会被删除,但我们鼓励所有用户迁移到对所有 Redux 代码使用 Redux Toolkit。
如果您想在没有此视觉弃用警告的情况下使用 createStore,请改用 legacy_createStore 导入:
从“redux”导入 { legacy_createStore as createStore}
“createStore”已弃用。ts(6385)
index.d.ts(375, 4):该声明曾在此处标注为已弃用。