UNPKG

json-joy

Version:

Collection of libraries for building collaborative editing apps.

12 lines (11 loc) 544 B
import * as React from 'react'; import { Chrome } from './Chrome'; import { context } from './context'; import { ToolbarState } from './state'; export const RenderPeritext = ({ surface, opts, children }) => { const value = React.useMemo(() => ({ surface, toolbar: new ToolbarState(surface, opts) }), [surface, opts]); const toolbar = value.toolbar; React.useLayoutEffect(() => toolbar.start(), [toolbar]); return (React.createElement(context.Provider, { value: value }, React.createElement(Chrome, null, children))); };