Mimikku
Mimikku
SSolidJS
Created by Mimikku on 2/29/2024 in #support
memo with dynamic props pass
am I doing something heavily retarded? I find myself doing this pattern a lot to enforce that props item is subscribed to
export interface AccordionProps {
items: AccordionItem[];
class?: string;
}

const Accordion = (props: AccordionProps) => {
const items = createMemo(
on(
() => props.items,
items => assignPaths(items),
),
);

return (
<ul class={cx('flex flex-col h-full overflow-auto px-2', props.class)}>
<For each={items} children={Item} />
</ul>
);
};
export interface AccordionProps {
items: AccordionItem[];
class?: string;
}

const Accordion = (props: AccordionProps) => {
const items = createMemo(
on(
() => props.items,
items => assignPaths(items),
),
);

return (
<ul class={cx('flex flex-col h-full overflow-auto px-2', props.class)}>
<For each={items} children={Item} />
</ul>
);
};
Or should I do something entirely else?
const items = createMemo(
on(
() => props.items,
items => assignPaths(items),
),
);
const items = createMemo(
on(
() => props.items,
items => assignPaths(items),
),
);
It just seems "Funny" I mean I could also use
const Accordion = (props: AccordionProps) => {
return (
<ul class={cx('flex flex-col h-full overflow-auto px-2', props.class)}>
<For each={assignPaths(props.items)} children={Item} />
</ul>
);
};
const Accordion = (props: AccordionProps) => {
return (
<ul class={cx('flex flex-col h-full overflow-auto px-2', props.class)}>
<For each={assignPaths(props.items)} children={Item} />
</ul>
);
};
6 replies