这是一个纯函数
store.subscribe(()=>{
// 重新渲染App,因为Diffing算法,只有改变的虚拟dom被重新渲染
ReactDOM.render(<App />,document.getElementById('root'));
})
redux里面有个applyMiddleware,在createstore中传入redux-thunk中的thunk并作为第二个参数 createStore(countReducer,applyMiddleware(thunk)) displash过去在ActionCreators停了下来,然后再走store,Renders
- 异步action中往往要开启一个同步action,以为异步到点了就要dispath了 store调的异步action,需要引入store,或者异步action函数传入一个displash,已经给我们准备好了
同步action都是对象,异步action都是函数,因为他要开启异步任务。一般不会用,没必要使用,但是面试可能会问