// define your components in one line:createComponent("docs-page");// AminJs will automagically load the associated html and css elements in the /template directory
What about javascript, my components have logic:
// shadow root is basically a smaller document for that element, You can still access the original document if you want. createComponent("docs-page",(shadowRoot)=>{consttitleBtn=shadowRoot.querySelector("#title");titleBtn.addEventListener("click",()=>alert("Clicked!"))},);
But What about States? I want reactivity:
// simply change the Amin.state.data object to apply changes to the uiAmin.state.data.counter++// the components that need to re-render will re-render// to pass a function to be called when the component needs to be re-rendered, simply you can return two things in the jsCallback, the re-render function and the clean-up function, the cleanup function will be called when the function is un-mounted
So a more complete definition of the createComopnent will be this: