2021-10-05 16:20:51 +00:00
|
|
|
import { hydrate, createComponent } from 'solid-js/web';
|
2021-07-21 23:10:03 +00:00
|
|
|
|
2021-07-27 12:51:20 +00:00
|
|
|
export default (element) => (Component, props, childHTML) => {
|
2021-12-02 16:30:15 +00:00
|
|
|
let children;
|
|
|
|
if (childHTML != null) {
|
|
|
|
children = document.createElement('astro-fragment');
|
|
|
|
children.innerHTML = childHTML;
|
|
|
|
}
|
2021-07-21 23:10:03 +00:00
|
|
|
|
2021-10-05 16:20:51 +00:00
|
|
|
// Using Solid's `hydrate` method ensures that a `root` is created
|
2021-07-27 12:51:20 +00:00
|
|
|
// in order to properly handle reactivity. It also handles
|
|
|
|
// components that are not native HTML elements.
|
2021-10-05 16:20:51 +00:00
|
|
|
hydrate(() => createComponent(Component, { ...props, children }), element);
|
2021-07-21 23:11:40 +00:00
|
|
|
};
|