【问题标题】:what are store, dispatch, payloads, types, actions, connect, thunk, reducers in react redux? [closed]react redux 中的 store、dispatch、payloads、types、actions、connect、thunk、reducers 是什么? [关闭]
【发布时间】:2017-08-31 23:51:46
【问题描述】:

react redux 中的 store、dispatch、payloads、types、actions、connect、thunk、reducers 是什么?

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')
)

【问题讨论】:

标签: reactjs react-redux


【解决方案1】:

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

这里有一个简短的总结:

Store:保存你的 redux 应用程序的状态

Dispatch:redux 提供的一个函数,允许您将操作发送到您的 redux 状态/reducers。

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

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

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

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

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

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

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

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-04-08
    • 2017-10-31
    • 1970-01-01
    • 1970-01-01
    • 2017-04-21
    • 2017-12-27
    • 2018-04-12
    • 2018-05-19
    相关资源
    最近更新 更多