fix(inulax): 修复状态管理器触发类组件重新渲染,shouldComponentUpdate不生效的问题

This commit is contained in:
huangxuan 2024-04-02 11:02:48 +08:00
parent aa4984f997
commit 4a825cec88
No known key found for this signature in database
GPG Key ID: E79F50C67022565D
1 changed files with 7 additions and 2 deletions

View File

@ -145,7 +145,12 @@ export function captureRender(processing: VNode): VNode | null {
processUpdates(processing, inst, nextProps);
// 如果 props, state, context 都没有变化且 isForceUpdate 为 false则不需要更新
shouldUpdate = oldProps !== processing.props || inst.state !== processing.state || processing.isForceUpdate;
shouldUpdate =
oldProps !== processing.props ||
inst.state !== processing.state ||
processing.isForceUpdate ||
// 响应式状态管理器中的值变化,需要更新
processing.isStoreChange;
if (shouldUpdate) {
// derivedStateFromProps会修改nextState因此需要调用
@ -167,7 +172,7 @@ export function captureRender(processing: VNode): VNode | null {
}
// 如果捕获了 error必须更新
const isCatchError = (processing.flags & DidCapture) === DidCapture;
shouldUpdate = isCatchError || shouldUpdate || processing.isStoreChange;
shouldUpdate = isCatchError || shouldUpdate;
// 更新ref
markRef(processing);