We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
// action通常是一个对象,在异步时会是一个函数 { type: 'userAction', // 肯定会有type属性 ...state // 其他扩展属性;state是一个对象,这里用到es6解构语法,把key-value对拷贝到当前对象 }
在真实App,最聪明的做法就是给每个Action构建最好尽量带上index来标记。
{ type: 'userAction', index: 5, ...state }
传统Flux的Action Creator:
function actionCreater (text) { const temp = { type: 'USER_ACTION', ...text } dispatch(temp) }
但是Redux的Action Creator是这样:
// action creator function addTodo (text) { return { type: 'USER_ACTION', ...text } } // 虽然不像Flux,但是可以模拟Flux做自动dispatch,唯一只做的就是调用actionCreater const actionCreater = text => { dispatch(addTodo(text)) } // 调用 actionCreater({ name: 'ljm' })
其实到最后也是调用这个函数返回的对象,用于传去Reducer。
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Action
在真实App,最聪明的做法就是给每个Action构建最好尽量带上index来标记。
Action Creator
传统Flux的Action Creator:
但是Redux的Action Creator是这样:
The text was updated successfully, but these errors were encountered: