Improve the interaction of your inputs with forms using hybrid rendering (LightDOM and ShadowDOM)
Normally we create webcomponents that only work with lightDOM or shadowDOM, example:
functioncomponentWithLightDom() {return ( <host> <h1>I am in the lightDOM</h1> </host> );}functioncomponentWithShadowDom() {return ( <hostshadowDom> <h1>I am inside the shadowDOM</h1> </host> );}
With atomico you can go further thanks to the hook @atomico/hooks/use-render which allows you to execute renders independent of the main one, example:
import { useRender } from"@atomico/hooks/use-render";functioncomponentWithLightDomAndShadowDom() {useRender(() => <h1>I am in the lightDOM</h1>);return ( <hostshadowDom> <h1>I am inside the shadowDOM</h1> </host> );}
What are the benefits of using useRender?
Encapsulate DOM fragments within custom Hooks and then render to any webcomponent.
patch the limitations of webcomponents that use shadowDOM, to improve communication with forms.
Patch the limitations of web components that use shadow DOM, to improve communication with forms
With the useRender(...) fragment we are managing to render an input in the lightDOM, thanks to this we will be able to control said input from inside the webcomponent.
Conclucion
Thanks to useRender you will be able to work together with LightDOM and shadowDOM from the scope of the webcomponent created with Atomico.