import React , { useMemo } from 'react' ; import { SimpleElement } from './SimpleElement' ; import { NodeId } from '../interfaces' ; import { NodeElement } from '../nodes/NodeElement' ; import { useInternalNode } from '../nodes/useInternalNode' ; export const DefaultRender = ( ) => { const { type , props , nodes , hydrationTimestamp } = useInternalNode ( ( node ) => ( { type : node . data . type , props : node . data . props , nodes : node . data . nodes , hydrationTimestamp : node . _hydrationTimestamp , } ) ) ; return useMemo ( ( ) => { let children = props . children ; if ( nodes && nodes . length > 0 ) { children = ( < React . Fragment > { nodes . map ( ( id ) => ( < NodeElement id = { id } key = { id } / > ) ) } < /React.Fragment>); } const render = React . createElement ( type , props , children ) ; if ( typeof type == 'string' ) { return < SimpleElement render = { render } />; } return render ; } , [ type , props , hydrationTimestamp , nodes ] ) ; } ;