Redux:有必要吗?
Redux: Is it necessary?
像Redux really necessary when developing with ReactJS这样的reducer吗?
它只是一种设计更简洁代码的方法吗?
如果是,什么时候?
React 只是一个可以构建的库 UI。不是一个完整的框架。使用 redux 可以让你以一种干净的方式处理应用程序的所有逻辑。还有其他类似于 redux 的库,但是 redux 似乎是用 react 开始一个新项目的方式。
简短的回答你不必使用 Redux 但如果你选择使用它对你来说要容易得多,网上有很多例子我可以指出你可以在哪里学习 Redux 和 React工作。请注意,React 只是 MVC 中的 V(视图层),据说 React 只做一项工作,而且它在显示用户界面方面做得非常好。
不,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.
像Redux really necessary when developing with ReactJS这样的reducer吗? 它只是一种设计更简洁代码的方法吗? 如果是,什么时候?
React 只是一个可以构建的库 UI。不是一个完整的框架。使用 redux 可以让你以一种干净的方式处理应用程序的所有逻辑。还有其他类似于 redux 的库,但是 redux 似乎是用 react 开始一个新项目的方式。
简短的回答你不必使用 Redux 但如果你选择使用它对你来说要容易得多,网上有很多例子我可以指出你可以在哪里学习 Redux 和 React工作。请注意,React 只是 MVC 中的 V(视图层),据说 React 只做一项工作,而且它在显示用户界面方面做得非常好。
不,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.