[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 Géry Debongnie
parent b20462ada6
commit b3c6ec2b48
4 changed files with 336 additions and 6 deletions
+10 -5
View File
@@ -201,13 +201,18 @@ export class ComponentNode<T extends typeof Component = typeof Component>
async updateAndRender(props: any, parentFiber: Fiber) {
// update
const root = this.fiber && this.fiber.root;
const fiber = makeChildFiber(this, parentFiber);
const parentRoot = parentFiber.root;
const rootChanged = root !== parentRoot;
this.fiber = fiber;
if (this.willPatch.length) {
parentFiber.root.willPatch.push(fiber);
}
if (this.patched.length) {
parentFiber.root.patched.push(fiber);
if (rootChanged) {
if (this.willPatch.length) {
parentRoot.willPatch.push(fiber);
}
if (this.patched.length) {
parentRoot.patched.push(fiber);
}
}
const component = this.component;
applyDefaultProps(props, component.constructor as any);