import * as React from "react" ; import * as ReactDOM from "react-dom" ; import { isString } from "lodash/fp" ; import { Pvjs as PvjsEl } from "./Pvjs" ; export type Pathway = Record < string , any > ; export type EntitiesById = Record < string , any > ; export class Pvjs { private _containerEl : any ; private _data : any ; private _element : React . Component ; private _renderMethod : "hydrate" | "render" ; constructor ( containerEl , data ) { this . _containerEl = containerEl ; this . _renderMethod = containerEl . innerHTML . trim ( ) === "" ? "render" : "hydrate" ; this . _data = data ; this . render ( ) ; } set data ( data ) { const { _containerEl , _data : prevData } = this ; const { pathway } = data ; this . _data = data ; this . _renderMethod = "render" ; this . render ( ) ; } render ( ) { const { _data , _renderMethod , _containerEl } = this ; const doRender = ReactDOM [ _renderMethod ] ; this . _element = doRender ( < PvjsEl { ... _data } / > , _containerEl ) ; } }