我正在试图弄清楚如何在redux中为商店设置初始状态.我以
https://github.com/reactjs/redux/blob/master/examples/todos-with-undo/reducers/index.js为例.我试图修改代码,以便todos初始化了一个值.
const todoApp = combineReducers({ todos,visibilityFilter },{ todos: [{id:123,text:'hello',completed: false}] })
遵循文档:http://redux.js.org/docs/api/createStore.html
但它不起作用,我不太清楚为什么.
它必须是createStore的第二个参数:
原文链接:https://www.f2er.com/react/301139.htmlconst rootReducer = combineReducers({ todos: todos,visibilityFilter: visibilityFilter }); const initialState = { todos: [{id:123,completed: false}] }; const store = createStore( rootReducer,initialState );