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

perf: 将createStore中hook执行后重新渲染的逻辑和StoreProvider内的子组件渲染解耦,避免引起不必要的渲染 #116

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

xiazimi
Copy link

@xiazimi xiazimi commented Apr 9, 2024

  1. 当前代码存在多重context的Provider嵌套,其作用只是为了传递StoreProvider中的子组件,可去除冗余代码。
  2. 当前 container.notify() 的组件作为StoreProvider子组件的父组件,在hook触发状态更新时,会导致StoreProvider子组件的重新渲染,本次PR,通过将container.notify()运行的虚拟组件StoreExecutor(这里的虚拟组件指无DOM渲染内容为null的组件)与跨组件传递container的StoreContext解耦,使得hook状态变更时,只会导致StoreExecutor虚拟组件的渲染,不会使被StoreContext包裹的没有使用useStore的业务子组件重新渲染。

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