summaryrefslogtreecommitdiff
path: root/packages/integrations/react/client.js
blob: 0579f4a08d3c736cbeb8f353e94b75a09f2448fa (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import { createElement } from 'react';
import { createRoot, hydrateRoot } from 'react-dom/client';
import StaticHtml from './static-html.js';

export default (element) => (Component, props, children, { client }) =>
	{
		const componentEl = createElement(
			Component,
			props,
			children != null
				? createElement(StaticHtml, { value: children })
				: children
		);
		if (client === 'only') {
			return createRoot(element).render(componentEl);
		}
		return hydrateRoot(element, componentEl);
	};