Skip to content

Comments

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

Open
xiazimi wants to merge 1 commit intoumijs:masterfrom
xiazimi:feat/createStore2Ref
Open

perf: 将createStore中hook执行后重新渲染的逻辑和StoreProvider内的子组件渲染解耦,避免引起不必要的渲染#116
xiazimi wants to merge 1 commit intoumijs:masterfrom
xiazimi:feat/createStore2Ref

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