[FIX] component: render in delayed willUpdateProps

Have a child component on which a render is triggered.
This component delays its willUpdateProps and makes a rendering during the willUpdateProps

Before this commit, renderings of the child were inconsistent across
its parent's renderings.

After this commit, it works as expected.
This commit is contained in:
Lucas Perais (lpe)
2021-12-04 18:35:31 +01:00
committed by Aaron Bohy
parent 6f435c36d8
commit 894deed13b
4 changed files with 424 additions and 10 deletions
+8 -7
View File
@@ -203,12 +203,6 @@ export class ComponentNode<T extends typeof Component = typeof Component>
// update
const fiber = makeChildFiber(this, parentFiber);
this.fiber = fiber;
if (this.willPatch.length) {
parentFiber.root.willPatch.push(fiber);
}
if (this.patched.length) {
parentFiber.root.patched.push(fiber);
}
const component = this.component;
applyDefaultProps(props, component.constructor as any);
const prom = Promise.all(this.willUpdateProps.map((f) => f.call(component, props)));
@@ -216,8 +210,15 @@ export class ComponentNode<T extends typeof Component = typeof Component>
if (fiber !== this.fiber) {
return;
}
this.component.props = props;
component.props = props;
this._render(fiber);
const parentRoot = parentFiber.root;
if (this.willPatch.length) {
parentRoot.willPatch.push(fiber);
}
if (this.patched.length) {
parentRoot.patched.push(fiber);
}
}
/**