summaryrefslogtreecommitdiff
path: root/packages/renderers/renderer-solid/client.js
blob: f4cdb4ead4e5c364f24a6ff108c1c6fe4d0d3e79 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
import { hydrate, createComponent } from 'solid-js/web';

export default (element) => (Component, props, childHTML) => {
  const children = document.createElement('astro-fragment');
  children.innerHTML = childHTML;

  // Using Solid's `hydrate` method ensures that a `root` is created
  // in order to properly handle reactivity. It also handles
  // components that are not native HTML elements.
  hydrate(() => createComponent(Component, { ...props, children }), element);
};