regionjs / rfcs

0 stars 0 forks source link

基于 region-core 的原理,复制 react 所有的 hooks 到全局 #4

Closed dancerphil closed 4 years ago

dancerphil commented 4 years ago

主要 api

const useState = createState();
const useReducer = createReducer();
const useMemo = createMemo();
// 以此类推

与 react 的区别

react hooks 提供了依托组件生命周期的 hooks,而 region-hooks 提供了依托 Application lifecycle 的 hooks

应用生命周期的 hooks 有什么特性?

dancerphil commented 4 years ago

一旦全局的 hooks 需要挂载 react 组件生命周期,上述部分特性会失效,所以这套东西还是不太有戏。

除此之外,跨组件 useMemo 好像也有点问题,要保证 b = f(a)b = f'(a) 成立就要约定 f = f',不约定的话又没用,也是个鸡肋。