Hi there!
I'm trying to pass callback to change the value of the Signal by child component.
const HeaderItem = component$<{
link: TLink;
onClickQrl: PropFunction<(prop: TBackground) => void>;
}>(({ link: { href, text } }) => {
const container = useSignal<HTMLElement>();
return (
<li
onClick$={() => {
if (container.value !== undefined) {
console.log({ width: container.value.offsetHeight });
}
// onClick({ width: 10, height: 10, left: 0 })
}}
>
<a ref={container} href={href}>
{text}
</a>
</li>
);
});
const LinksHandler = component$<{ links: TLink[] }>(({ links }) => {
const fillProps = useSignal<TBackground>();
const linksAggregate = links.map((l) => (
<HeaderItem
onClickQrl={$(() => {
console.log("works");
})}
key={l.href}
link={l}
/>
));
// TODO prefetching
return (
<>
<ul>
{linksAggregate}
<button onClick$={$(toggleContact)}>Contact</button>
</ul>
<div style={fillProps.value}> background </div>
</>
);
});
Error:
9:37:27 PM [vite] Internal server error: Optimizer should replace all usages of $() with some special syntax. If you need to create a QRL manually, use inlinedQrl() instead.
What's wrong with my code?
Runtime: Bun