fix: should add subscribe after hot load #13
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
在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永远只返回热更新前的最后一次的结果