简体   繁体   English

使用哪个 React hooks 或 Redux

[英]Which to use React hooks or Redux

I need to create authentication with reactjs and node/express.我需要使用 reactjs 和 node/express 创建身份验证。 Previously I did that with redux and right now I am not up-to-date with react-hooks.I saw somewhere in article that this can replace redux.This is little confusing for me, so I need good suggestion about this, and if you can share some article or example of react(updated) node/express authentication,then please share.以前我是用 redux 做的,现在我不是最新的 react-hooks。我在文章的某处看到它可以代替 redux分享一些react(更新)节点/快速身份验证的文章或示例,然后请分享。 Thanks for attention to my wired question))))))感谢您关注我的有线问题))))))

It really depends on what you want to do with your app.这真的取决于你想用你的应用程序做什么。 When you deal with more complex logic or flows in your application, I personally prefer Redux for making the code cleaner and easier to manage.当您在应用程序中处理更复杂的逻辑或流程时,我个人更喜欢 Redux 以使代码更清晰,更易于管理。 If it's a simpler flow application, you can definitely leverage on hooks and context to create your own state management as good as Redux.如果它是一个更简单的流应用程序,您绝对可以利用钩子和上下文来创建您自己的 state 管理和 Redux 一样好。

However, if the application ever has the potential to grow into a complex app (like requires middleware, debugging tools, etc.) I'd recommend starting with Redux so you don't have to switch from hooks into Redux later.但是,如果应用程序有可能发展成复杂的应用程序(例如需要中间件、调试工具等),我建议从 Redux 开始,这样您以后就不必从挂钩切换到 Redux。

First, understand what Redux offers (and how it helps in a complex app):首先,了解 Redux 提供了什么(以及它如何帮助复杂的应用程序):

Some related good articles as requested, if you want to build your own redux-hooks:如果您想构建自己的 redux-hooks,请按要求提供一些相关的好文章:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM