Redux 的 createStore 在编辑器中被提示弃用

in js •  3 months ago 

在 React 18 中,createStoreRedux 提供的一个函数,用于创建 Redux store,但从 Redux Toolkit v5 开始,createStore 已被标记为弃用,并建议使用 configureStore 作为替代。

configureStoreRedux Toolkit 中提供的一个函数,它简化了 Redux 的配置过程,内置了 Redux DevTools、默认的中间件配置等。

下面是如何使用 configureStore 替代 createStore 的一个简单示例:

import { configureStore } from '@reduxjs/toolkit';
import rootReducer from './reducers';

const store = configureStore({
  reducer: rootReducer,
});

export default store;

这次重构 faucet 将会替换掉 createStore 方法。


ET碎碎念,每周更新,欢迎订阅,点赞,转发!


好用不贵的VPS推荐

https://1hour.win


感谢你的阅读,我是中文区见证人之一,欢迎通过 AuthSteem 来给我投票,或者打开 https://steemitwallet.com/~witnesses 页面,输入 ety001 进行投票。

2.gif

中文区的见证人目前有:
支持一下他们(按字母顺序),一人可以有30票


Thank you for reading. I'm a witness. I would really appreciate your witness vote! You can vote by SteemLogin. Or open https://steemitwallet.com/~witnesses page, input ety001 to vote.

2.gif

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!
Sort Order:  

"😊 Nice write-up on the changes in Redux! 🤩 The example code snippet is super helpful too. 👍 I've been using configureStore since v5, and it's made my life so much easier. 💪 Thanks for sharing this valuable info with us, @ET碎碎念! 👋 If you're looking for more resources or want to discuss this topic further, feel free to share your thoughts in the comments below. 🤔 Don't forget to give a thumbs-up and subscribe for more weekly updates! 😊 And as a special request, would you mind voting for our community's witness, @xpilar.witness? 💖 Just head over to https://steemitwallet.com/~witnesses and input xpilar.witness to show your support. Thanks in advance, everyone! 👍"