S
SolidJS2y ago
Max

Are there any important considerations to creating signals in control component callbacks like For

Hi, wondering if there's anything to consider in terms of tracking etc in having something like this
<For each={props.data}>
{(data) => {
const [isOpen, setOpen] = createSignal(false);
return <Component data={data} isOpen={isOpen} onClick={()=>setOpen(x=>!x)}/>;
}}
</For>
<For each={props.data}>
{(data) => {
const [isOpen, setOpen] = createSignal(false);
return <Component data={data} isOpen={isOpen} onClick={()=>setOpen(x=>!x)}/>;
}}
</For>
Or if it's actually better to have some intermediary component where the signal to track state is declared in jsx. Thanks
2 Replies
thetarnav
thetarnav2y ago
It's absolutely fine
Max
MaxOP2y ago
ah thats beautiful thanks

Did you find this page helpful?