Skip to content

Commit 832b1b6

Browse files
committed
fix(react): run all pending renderComponent before hydrate
Run all pending `renderComponent` before hydrate, which ensures some immediate update can be applied in `hydrate`. As background info, ReactLynx will use tree in background-thread as the source-of-truth, so this PR is helpful if main-thread renders more than background-thread's `root.render` by avoiding unwanted node removals.
1 parent 44f5b0d commit 832b1b6

File tree

1 file changed

+3
-1
lines changed
  • packages/react/runtime/src/lynx

1 file changed

+3
-1
lines changed

packages/react/runtime/src/lynx/tt.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright 2024 The Lynx Authors. All rights reserved.
22
// Licensed under the Apache License Version 2.0 that can be found in the
33
// LICENSE file in the root directory of this source tree.
4-
import { render } from 'preact';
4+
import { process, render } from 'preact';
55

66
import { LifecycleConstant, NativeUpdateDataType } from '../lifecycleConstant.js';
77
import type { FirstScreenData } from '../lifecycleConstant.js';
@@ -69,6 +69,8 @@ function onLifecycleEvent([type, data]: [LifecycleConstant, unknown]) {
6969
function onLifecycleEventImpl(type: LifecycleConstant, data: unknown): void {
7070
switch (type) {
7171
case LifecycleConstant.firstScreen: {
72+
process();
73+
7274
const { root: lepusSide, jsReadyEventIdSwap } = data as FirstScreenData;
7375
if (__PROFILE__) {
7476
console.profile('hydrate');

0 commit comments

Comments
 (0)