This commit is contained in:
@@ -6,6 +6,6 @@ import { TestUi1Component } from "./TestUi1Component"
|
||||
export default class TestUi1 extends Control {
|
||||
// Called when the node enters the scene tree for the first time.
|
||||
_ready(): void {
|
||||
Renderer.render(React.createElement(TestUi1Component), this)
|
||||
Renderer.renderComponent(this, TestUi1Component)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,26 @@
|
||||
/** biome-ignore-all lint/complexity/noBannedTypes: {} is the "empty props" type in React */
|
||||
import type { Node, NodePathMap } from "godot"
|
||||
import * as React from "react"
|
||||
import * as Reconciler from "./Reconciler.js"
|
||||
|
||||
|
||||
const ConcurrentRoot = 1
|
||||
|
||||
export const render = (element: React.ReactNode, container: Node<NodePathMap>, callback?: () => void): number => {
|
||||
export const renderComponent: {
|
||||
(
|
||||
container: Node<NodePathMap>,
|
||||
component: React.FC<{}>,
|
||||
): void
|
||||
<P>(
|
||||
container: Node<NodePathMap>,
|
||||
component: React.FC<P>,
|
||||
props: NoInfer<P>,
|
||||
): void
|
||||
} = (
|
||||
container: Node<NodePathMap>,
|
||||
component: React.FC<{}>,
|
||||
props?: Record<string, unknown>,
|
||||
): void => {
|
||||
const reconciler = Reconciler.make()
|
||||
|
||||
if (!(container as any)._rootContainer)
|
||||
@@ -18,10 +34,9 @@ export const render = (element: React.ReactNode, container: Node<NodePathMap>, c
|
||||
console.error,
|
||||
)
|
||||
|
||||
return reconciler.updateContainer(
|
||||
element,
|
||||
reconciler.updateContainer(
|
||||
React.createElement(component, props),
|
||||
(container as any)._rootContainer,
|
||||
null,
|
||||
callback,
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user