perf: 将createStore中hook执行后重新渲染的逻辑和StoreProvider内的子组件渲染解耦,避免引起不必要的渲染#116
Open
xiazimi wants to merge 1 commit intoumijs:masterfrom
Open
perf: 将createStore中hook执行后重新渲染的逻辑和StoreProvider内的子组件渲染解耦,避免引起不必要的渲染#116xiazimi wants to merge 1 commit intoumijs:masterfrom
xiazimi wants to merge 1 commit intoumijs:masterfrom
Conversation
xiazimi
commented
Apr 9, 2024
- 当前代码存在多重context的Provider嵌套,其作用只是为了传递StoreProvider中的子组件,可去除冗余代码。
- 当前 container.notify() 的组件作为StoreProvider子组件的父组件,在hook触发状态更新时,会导致StoreProvider子组件的重新渲染,本次PR,通过将container.notify()运行的虚拟组件StoreExecutor(这里的虚拟组件指无DOM渲染内容为null的组件)与跨组件传递container的StoreContext解耦,使得hook状态变更时,只会导致StoreExecutor虚拟组件的渲染,不会使被StoreContext包裹的没有使用useStore的业务子组件重新渲染。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.