11import reconciler , { appContainer } from "../reconciler" ;
2- import { Reconciler } from "react-reconciler" ;
2+ import ReactReconciler , { Reconciler } from "react-reconciler" ;
3+ import React from "react" ;
34import { NodeWidget } from "@nodegui/nodegui" ;
5+ import { RNComponent } from "../components/config" ;
6+ //@ts -ignore
7+ import deepForceUpdate from "react-deep-force-update" ;
48
5- type NodeGuiReconciler = Reconciler < NodeWidget , any , Set < NodeWidget > , any > ;
9+ type NodeGuiReconciler = Reconciler < RNComponent , any , Set < NodeWidget > , any > ;
610
711export type RendererOptions = {
812 onRender ?: ( ) => void ;
@@ -13,15 +17,23 @@ const defaultOptions = {
1317 onRender : ( ) => { }
1418} ;
1519
16- export const Renderer = {
17- render ( element : React . ReactNode , options ?: RendererOptions ) {
20+ export class Renderer {
21+ static container ?: ReactReconciler . FiberRoot ;
22+ static forceUpdate ( ) {
23+ if ( Renderer . container ) {
24+ //@ts -ignore
25+ Renderer . container . _reactInternalInstance = Renderer . container . current ;
26+ deepForceUpdate ( Renderer . container ) ;
27+ }
28+ }
29+ static render ( element : React . ReactNode , options ?: RendererOptions ) {
1830 const containerInfo = appContainer ;
1931 const isConcurrent = false ; //disabling since there seems to be a bug with onclick listeneres (when called without a console.log inside them)
2032 const hydrate = false ;
2133
2234 const rendererOptions = Object . assign ( { } , defaultOptions , options ) ;
2335
24- const container = reconciler . createContainer (
36+ Renderer . container = reconciler . createContainer (
2537 containerInfo ,
2638 isConcurrent ,
2739 hydrate
@@ -30,8 +42,13 @@ export const Renderer = {
3042 rendererOptions . onInit ( reconciler ) ;
3143
3244 const parentComponent = null ; // Since there is no parent (since this is the root fiber). We set parentComponent to null.
33- reconciler . updateContainer ( element , container , parentComponent , ( ) => {
34- rendererOptions . onRender ( ) ;
35- } ) ; // Start reconcilation and render the result
45+ reconciler . updateContainer (
46+ element ,
47+ Renderer . container ,
48+ parentComponent ,
49+ ( ) => {
50+ rendererOptions . onRender ( ) ;
51+ }
52+ ) ; // Start reconcilation and render the result
3653 }
37- } ;
54+ }
0 commit comments