Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

请问:useEffect在commit的layout阶段执行的原因? #39

Closed
Fhasghrge opened this issue Sep 24, 2020 · 2 comments
Closed

请问:useEffect在commit的layout阶段执行的原因? #39

Fhasghrge opened this issue Sep 24, 2020 · 2 comments

Comments

@Fhasghrge
Copy link

image
楼主你好:
在layout阶段可以执行useEffect的调用和销毁,一般不是在before mutation执行useEffect的回调,在delete某个节点时执行useEffect执行销毁。
如果在layout执行其调用和销毁,不是清楚了before mutation中执行的回调?
此外我的这个代码在页面渲染完成,也就是layout并没有发现页面的标题发生了改变?
useEffect(() => { return () => { document.title='???' } }, [])
谢谢帮忙解答💕

@BetaSu
Copy link
Owner

BetaSu commented Sep 25, 2020

这里是调度useEffect的回调,并不是调用他。 调用是在commit阶段完成后异步执行的,而执行的回调就来自于调度

@Fhasghrge
Copy link
Author

我理解了,就是对useEffect本身进行回调进行处理

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants