…state,
{
id: action.id,
text: action.text,
completed: false
}
]
default:
return state
}
}
export default todos
index.js
import React from ‘react’;
import ReactDOM from ‘react-dom’;
import {applyMiddleware,createStore} from ‘redux’;
import logger from ‘redux-logger’;
import ‘./index.css’;
import App from ‘./App’;
import * as actions from ‘./actions’;
import reducers from ‘./reducers’;
import registerServiceWorker from ‘./registerServiceWorker’;
const store = createStore(reducers,applyMiddleware(logger));
store.dispatch(actions.addTodo(‘add ToDo’));
ReactDOM.render(, document.getElementById(‘root’));
registerServiceWorker();
以上代码运行结果如下所示:
![](https://imgconvert.csdnimg.cn/aHR0cHM6Ly9tbWJpei5xcGljLmNuL21tYml6X3BuZy9GYWVEZElmZXVxN