astro/packages/integrations/solid/client.js
Fred K. Schott 6386c14d00
Astro Integration System (#2820)
* update examples

* add initial integrations

* update tests

* update astro

* update ci

* get final tests working

* update injectelement todo

* update ben code review

* respond to final code review feedback
2022-03-18 15:35:45 -07:00

14 lines
513 B
JavaScript

import { hydrate, createComponent } from 'solid-js/web';
export default (element) => (Component, props, childHTML) => {
let children;
if (childHTML != null) {
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);
};