我一直遇到这个错误!
错误:期望根减速器是一个函数。相反,收到:“未定义”
我已经尝试了所有我能找到的答案都无济于事,这里是所有相关的东西!
根减速机
const createRootReducer = (history) => {
combineReducers({
router: connectRouter(history),
createUser: signupReducer,
});
};
export default createRootReducer;
Run Code Online (Sandbox Code Playgroud)
根
const Root = ({ children, initialState = {} }) => {
const history = createBrowserHistory();
const middleware = [thunk, routerMiddleware(history)];
const store = createStore(rootReducer(history), initialState, applyMiddleware(...middleware));
return (
<Provider store={store}>
<ConnectedRouter history={history}>{ children }</ConnectedRouter>
</Provider>
);
};
export default Root;
Run Code Online (Sandbox Code Playgroud)
应用程序
function App() {
return (
<div className="App">
<Root>
<ToastContainer hideProgressBar={true} newestOnTop={true} />
<Navbar />
<Landing />
<PostList /> …Run Code Online (Sandbox Code Playgroud)