createStore(reducer, [preloadedState], [enhancer])
Arguments
Returns
Example
import { createStore } from "redux";
function todos(state = [], action) {
switch (action.type) {
case "ADD_TODO":
return state.concat([action.text]);
default:
return state;
}
}
let store = createStore(todos, ["Use Redux"]);
store.dispatch({
type: "ADD_TODO",
text: "Read the docs",
});
console.log(store.getState());
// [ 'Use Redux', 'Read the docs' ]Tips
Last updated