Teact: Fix missing layout effects after first render
This commit is contained in:
parent
a11ef0f618
commit
ad9e1bb9a1
@ -18,6 +18,7 @@ import {
|
||||
renderComponent,
|
||||
unmountComponent,
|
||||
isFragmentElement,
|
||||
runImmediateEffects,
|
||||
} from './teact';
|
||||
import { DEBUG } from '../../config';
|
||||
import { addEventListener, removeAllDelegatedListeners, removeEventListener } from './dom-events';
|
||||
@ -55,6 +56,9 @@ function render($element: VirtualElement | undefined, parentEl: HTMLElement) {
|
||||
|
||||
const $head = headsByElement.get(parentEl)!;
|
||||
const $newElement = renderWithVirtual(parentEl, $head.children[0], $element, $head, 0);
|
||||
|
||||
queueMicrotask(runImmediateEffects);
|
||||
|
||||
$head.children = $newElement ? [$newElement] : [];
|
||||
|
||||
if (process.env.APP_ENV === 'perf') {
|
||||
|
||||
@ -335,6 +335,10 @@ const runUpdatePassOnRaf = throttleWithRafFallback(() => {
|
||||
forceUpdateComponent(instance);
|
||||
});
|
||||
|
||||
runImmediateEffects();
|
||||
});
|
||||
|
||||
export function runImmediateEffects() {
|
||||
const currentLayoutCleanups = pendingLayoutCleanups;
|
||||
pendingLayoutCleanups = new Map();
|
||||
currentLayoutCleanups.forEach((cb) => cb());
|
||||
@ -342,7 +346,7 @@ const runUpdatePassOnRaf = throttleWithRafFallback(() => {
|
||||
const currentLayoutEffects = pendingLayoutEffects;
|
||||
pendingLayoutEffects = new Map();
|
||||
currentLayoutEffects.forEach((cb) => cb());
|
||||
});
|
||||
}
|
||||
|
||||
function scheduleUpdate(componentInstance: ComponentInstance) {
|
||||
instancesPendingUpdate.add(componentInstance);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user