
1 ech0x 2019-06-26 06:46:17 +08:00 via iPhone “ Hooks are functions that let you “ hook into ” React state and lifecycle features from function components. Hooks don ’ t work inside classes they let you use React without classes. (We don ’ t recommend rewriting your existing components overnight but you can start using Hooks in the new ones if you ’ d like.)” 我不懂 Javascript,不过看这个描述应该是不一样的 hook 跟 react 生命周期有关。 python 的装饰器只是高级函数的语法糖而已。 |
2 jason94 2019-06-26 07:57:09 +08:00 两个完全不一样的东西~~建议补一补基础,先把两者的定义弄明白了。 |
3 byenow 2019-06-26 13:22:16 +08:00 @decorator 是对 Class 的修改,基于 Class Components,React Hooks 基于 Function Components |
4 bestie 2019-06-27 09:44:08 +08:00 decorator 更类似于高阶函数( HOC ) |
5 azh7138m 2019-07-09 15:49:21 +08:00 完全不一样的东西,建议阅读 https://github.com/acdlite/recompose decorator 怎么就 hoc 了。。。 |
6 ahonn 2019-07-21 11:15:57 +08:00 看完这个你就懂了 |