7 ms·
Definitely correct me if I'm wrong, but I also thought hooks were for factoring out common logic and sharing it among functional components. I see lots of "hoo
by pure 7y ago
Definitely correct me if I'm wrong, but I also thought hooks were for factoring out common logic and sharing it among functional components. I see lots of "hooks" libraries floating around.
For Context, like you said, it existed before, but everyone was told not to use it. After the new API came out, people started suggesting ditching Redux for Context, and I know a lot of people did that. Using Context in that way is very similar to creating a stateful service in Angular and injecting it into your components.
- ng12 7y agoHooks are used for abstracting component state logic. React is just as agnostic concerning how you implement your business logic as ever.
- nicoburns 7y agoI agree that the pattern of "services" is a good one. But you don't really need Angular's DI for this in javascript. You can just use an ES6 module.
- bradstewart 7y agoUnless you care about the scope/lifecycle of the service. Or want to easily replace its implementation in different contexts (like tests).
- ng12 7y agoMost test frameworks allow you to stub imports. DI is just one of the many wheels Angular has reinvented.