什么是存储,调度,有效负载,类型,操作,连接,thunk,reducer在react redux?

时间:2017-04-06 06:01:44

标签: reactjs react-redux

什么是存储,调度,有效负载,类型,操作,连接,thunk,reducers in react redux ??

import { createStore, applyMiddleware } from 'redux'
import thunk from 'redux-thunk'
const createStoreWithMiddleware = applyMiddleware(thunk)(createStore)
const store = createStoreWithMiddleware(reducer)
ReactDOM.render(
 <MuiThemeProvider muiTheme={muiTheme}>
   <Provider store={store}>
       <Router history={ browserHistory }>
         <Route path="/" component={ Content }/>
         <Route path="/filter" component={ Filter }/>
         <Route path="/details" component={ Details }/>
       </Router>
   </Provider>
 </MuiThemeProvider>,
   document.getElementById('root')
)

1 个答案:

答案 0 :(得分:6)

用一句话很难回答这个问题。有些人指出,教程是一个很好的起点。

以下是一个快速摘要:

商店:保存您的redux应用程序的状态

Dispatch :redux提供的一个函数,允许您向redux state / reducers发送操作。

有效负载:操作的内容/消息。将其与电子邮件的消息进行比较。

类型:正在发送的操作类型。将其与电子邮件的主题进行比较。

操作:您告诉redux做某事。将其与电子邮件本身进行比较。

连接:redux提供的函数,允许您将react(或其他框架/语言)组件连接到redux状态。

Thunk :用于管理redux中的异步操作的Lib。另一个lib是redux sagas。

Reducers :Reducers定义/更新您的状态并响应发送给redux的操作。

非常苛刻的解释。如果您想要更好的解释,教程是一个更好的起点,当您掌握基本概念时,您可以在SO上询问/搜索更具体的问题。

编辑:欢迎对我的解释进行更正/改进

相关问题