NodeJS 如何在configureStore中打开createStore [已关闭]

sbdsn5lh  于 2023-03-22  发布在  Node.js
关注(0)|答案(1)|浏览(85)

已关闭。此问题需要details or clarity。当前不接受答案。
**想要改进此问题?**添加详细信息并通过editing this post阐明问题。

3天前关闭。
Improve this question
我需要在configureStore代码中转换createStore代码
我试着把它转过来,但没有成功:

import { createStore, applyMiddleware } from 'redux'
import { Provider } from 'react-redux'
import thunk from 'redux-thunk'

import rootReducer from './reducers/index'

import { composeWithDevTools } from 'redux-devtools-extension'

const store = createStore(
    rootReducer,
    composeWithDevTools(applyMiddleware(thunk))
)

const DataProvider = ({ children }) => {
    return (
        <Provider store={store}>
            {children}
        </Provider>
    )
}

export default DataProvider
s5a0g9ez

s5a0g9ez1#

configureStore@reduxjs/toolkit包的一部分:

import { configureStore } from '@reduxjs/toolkit'
import thunk from 'redux-thunk'

import rootReducer from './reducers/index'

const store = configureStore({
    reducer: rootReducer,
    middleware: [thunk],
    devTools: true
})

const DataProvider = ({ children }) => {
    return (
        <Provider store={store}>
            {children}
        </Provider>
    )
}

export default DataProvider

相关问题