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

fix: should add subscribe after hot load #13

Open
wants to merge 4 commits into
base: v0.2.x
Choose a base branch
from

Conversation

bigbossx
Copy link

@bigbossx bigbossx commented Jun 7, 2024

在hot reload的case 下,组件实例会复用状态,也就是lastStore 不再为undefined。也就是当一次hot-reload 发生后,新的useSelector不会再为新的module产物添加订阅。

但是useEffect 的disposer 会执行,导致当前useSelector的订阅被完全移除。

所造成的影响是,后续就会出现dispatch 触发,不会再触发订阅重新执行,组件将每次只执行非update状态下的selector diff。

如果当前selector不是一个factor,而是一个box,那根据这里的re select,result可以获得正确的结构。

但是如果当前selector 是一个factor,selectorChanged 会判断factor args length长度一致,不再re select,导致result永远只返回热更新前的最后一次的结果

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

Successfully merging this pull request may close these issues.

1 participant