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