Closed ArthurClemens closed 3 years ago
which version of the loader are you using?
it is also possible you push twice the same component ... the last else
should likely be instead:
else if (this.q.indexOf(component) < 0)
this.q.push(component);
actually ... it is very possible you are trying to inject uce-template itself, or you import uce-template somewhere in your code
use-loader
from npm, so version 2.0.0
.uce-template
.Not sure what I am doing wrong.
that is not a reproducible example to me ... there's no layout, no live-demo, so if you could provide that, it'd be awesome.
I have created a test repo: https://github.com/ArthurClemens/nextjs-uce-template
@ArthurClemens two issues:
.uce
file, but you expose a generic htmlelement extend on the page<template is="uce-template">
only if rendered on the page, files don't need thatTo solve point 1 (index.js):
export default function Home() {
useUceLoader();
return (
<>
Page
<button is="my-btn" />
</>
);
to solve point 2 (my-btn.uce):
<button is="my-btn">Clicked {{ times }} times!</button>
<script type="module">
const states = new WeakMap();
export default {
setup(element) {
const state = { times: 0 };
states.set(element, state);
return state;
},
onClick() {
states.get(this).times++;
// update the current view if the
// state is not reactive
this.render();
},
};
</script>
also note you can just name uce-btn.html
and change the loader accordingly, if your editor doesn't handle .uce
extensions 👋
Clear. Thanks for the help!
Thank you, I've just realized there is a bug with events set directly on the component ...
Amending: there was no bug, but the lib just got updated with better useEffect
lifecycle.
I am trying out a new project with NextJS with uce-template, and I am getting a dreaded error:
The code is not spectacular: