state - 终极版 : Is it necessary?

标签 state reactjs

是像 Redux 这样的 reducer 吗?使用 ReactJS 进行开发时确实有必要? 这只是设计更简洁代码的一种方法吗? 如果是的话,什么时候?

最佳答案

不,reducer 或 Redux 不是必需的。 Vanilla React 工作正常,或者其他选项,例如MobX。

查看 Redux FAQ :

Dan Abramov, one of the creators of Redux, says:

...don’t use Redux until you have problems with vanilla React.

何时使用 Redux 是一种架构意见,常见问题解答提供了以下指南:

In general, use Redux when you have reasonable amounts of data changing over time, you need a single source of truth, and you find that approaches like keeping everything in a top-level React component’s state are no longer sufficient.

关于state - 终极版 : Is it necessary?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37619223/

相关文章:

html - 动态更新css类属性

javascript - 一次只有一个按钮处于事件状态,具体取决于状态

javascript - React.js : Props not being received by child component

javascript - react 路由器 BrowserRouter 与 typescript react 的问题?

reactjs - React 'this' 在 Chrome 开发者工具中未定义

reactjs - 如何在 Material UI 中布局表单?

AngularJS - 如何从 Controller 内部更改状态

database - 对方在意外时间发送 session 拒绝消息,消息无法建立 session

c++ - 写入和读取随机数状态到文件

javascript - 本地存储值更改后页面未更新,REACT