refactor: deferred React render
This commit is contained in:
parent
bba6c64410
commit
a4b33ba3b9
|
@ -256,10 +256,11 @@ export class App extends decorate(class {}) {
|
|||
|
||||
onPacket(packet) {
|
||||
if (!this.hasReceivedState) {
|
||||
this.renderIntoDom(document.querySelector('.app'));
|
||||
this.startProcessingInput();
|
||||
this.startSimulation();
|
||||
this.startRendering();
|
||||
this.renderIntoDom(document.querySelector('.app')).then(() => {
|
||||
this.startProcessingInput();
|
||||
this.startSimulation();
|
||||
this.startRendering();
|
||||
});
|
||||
this.hasReceivedState = true;
|
||||
}
|
||||
if (packet instanceof BundlePacket) {
|
||||
|
@ -439,13 +440,24 @@ export class App extends decorate(class {}) {
|
|||
this.reactContainer = this.createReactContainer();
|
||||
this.stage.ui.appendChild(this.reactContainer);
|
||||
const UiComponent = <Ui app={this} />;
|
||||
ReactDOM.render(UiComponent, this.reactContainer, () => {
|
||||
this.stage.flushUiElements();
|
||||
});
|
||||
// Debug UI.
|
||||
this.debugUiNode = node.querySelector('.debug-container');
|
||||
const DebugUiComponent = <DebugUi app={this} />;
|
||||
ReactDOM.render(DebugUiComponent, this.debugUiNode);
|
||||
// Deferred render.
|
||||
return Promise.all([
|
||||
promise,
|
||||
new Promise((resolve) => {
|
||||
ReactDOM.render(UiComponent, this.reactContainer, () => {
|
||||
this.stage.flushUiElements();
|
||||
resolve();
|
||||
});
|
||||
}),
|
||||
new Promise((resolve) => {
|
||||
ReactDOM.render(DebugUiComponent, this.debugUiNode, () => {
|
||||
resolve();
|
||||
});
|
||||
}),
|
||||
]);
|
||||
}
|
||||
|
||||
setActiveSlotIndex(slotIndex) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user