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

函数组件中页面表现与react的实际状态不一致 #9

Closed
mouse-007 opened this issue Nov 18, 2021 · 1 comment
Closed

函数组件中页面表现与react的实际状态不一致 #9

mouse-007 opened this issue Nov 18, 2021 · 1 comment

Comments

@mouse-007
Copy link

函数组件中,页面的状态与组件实际状态不一致,页面更像是一个快照,函数组件中的state都被初始化了。
函数组件有一个输入框 值为5,再次进入时页面也显示5,但是打印出来的却是初始值。感觉真实dom与react虚拟dom不一致。

@GoodLuckAlien
Copy link
Owner

函数组件中,页面的状态与组件实际状态不一致,页面更像是一个快照,函数组件中的state都被初始化了。 函数组件有一个输入框 值为5,再次进入时页面也显示5,但是打印出来的却是初始值。感觉真实dom与react虚拟dom不一致。

方便提供一下代码片段吗?正常情况下,不会出现这个问题,因为被缓存的组件,在 keepalive 期间,是不会被销毁的

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