UNPKG

json-joy

Version:

Collection of libraries for building collaborative editing apps.

9 lines (8 loc) 363 B
import * as React from 'react'; import { context } from './context'; import { CursorState } from './state'; export const RenderPeritext = ({ ctx, children }) => { const state = React.useMemo(() => new CursorState(ctx), [ctx]); React.useEffect(() => state.start(), [state]); return React.createElement(context.Provider, { value: state }, children); };