This commit is contained in:
@@ -6,6 +6,6 @@ import { TestUi1Component } from "./TestUi1Component"
|
|||||||
export default class TestUi1 extends Control {
|
export default class TestUi1 extends Control {
|
||||||
// Called when the node enters the scene tree for the first time.
|
// Called when the node enters the scene tree for the first time.
|
||||||
_ready(): void {
|
_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 type { Node, NodePathMap } from "godot"
|
||||||
|
import * as React from "react"
|
||||||
import * as Reconciler from "./Reconciler.js"
|
import * as Reconciler from "./Reconciler.js"
|
||||||
|
|
||||||
|
|
||||||
const ConcurrentRoot = 1
|
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()
|
const reconciler = Reconciler.make()
|
||||||
|
|
||||||
if (!(container as any)._rootContainer)
|
if (!(container as any)._rootContainer)
|
||||||
@@ -18,10 +34,9 @@ export const render = (element: React.ReactNode, container: Node<NodePathMap>, c
|
|||||||
console.error,
|
console.error,
|
||||||
)
|
)
|
||||||
|
|
||||||
return reconciler.updateContainer(
|
reconciler.updateContainer(
|
||||||
element,
|
React.createElement(component, props),
|
||||||
(container as any)._rootContainer,
|
(container as any)._rootContainer,
|
||||||
null,
|
null,
|
||||||
callback,
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user