能不能添加一个useSyncEffect的hook? #2361
lovetingyuan
started this conversation in
Ideas
Replies: 1 comment
-
其实可以直接用useMemo |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
useSyncEffect可以在依赖变化时同步执行回调,可以触发react的eager render,避免useEffect里更新状态带来的二次渲染开销。
这里有个简单的实现
或者可以叫 useOnChange或者useEagerEffect
Beta Was this translation helpful? Give feedback.
All reactions