bokuno_disk_cord
bokuno_disk_cord
SSolidJS
Created by bokuno_disk_cord on 4/6/2023 in #support
Index block does not notice change in a store
i thought, it already is. its in the tutorial afterall. https://www.solidjs.com/docs/latest/api#createmutable
12 replies
SSolidJS
Created by bokuno_disk_cord on 4/6/2023 in #support
Index block does not notice change in a store
tobe clear, with my original code, Index does notice on item removed and added to the list. but not an individual item. produce does exactly what i need. but IDK why it's necessary. there is also createMutable and modifyMutable which remove the need for produce. i guess, i'll use them instead.
12 replies
SSolidJS
Created by bokuno_disk_cord on 4/6/2023 in #support
Index block does not notice change in a store
produce works. hm....
12 replies
SSolidJS
Created by avant on 1/5/2023 in #support
Image loading SSR
Have you try suspense block with fallback element?
3 replies
SSolidJS
Created by bokuno_disk_cord on 1/5/2023 in #support
can i propagate event to child?
and i'd use List component like this?
const App: Component = () => {
return (
<List
items={[
Child,
Child,
Child,
Child,
Child,
Child,
Child,
Child,
Child,
]}
/>
);
};
const App: Component = () => {
return (
<List
items={[
Child,
Child,
Child,
Child,
Child,
Child,
Child,
Child,
Child,
]}
/>
);
};
thanks for your help 👍, that's the last question for today. i'll keep the thread open to see feedback from other members.
26 replies
SSolidJS
Created by bokuno_disk_cord on 1/5/2023 in #support
can i propagate event to child?
idk what to pass to List and each Child
26 replies
SSolidJS
Created by bokuno_disk_cord on 1/5/2023 in #support
can i propagate event to child?
interface event {
idx: number;
el: JSXElement;
}

const List: FlowComponent<{ click: Setter<event> }, JSXElement[]> = (props) => {
return (
<ul>
<For each={props.children}>
{(el, idx) => (
<li
style={'padding:2rem;border:1pt dashed violet;'}
{/* i want to pass trigger something in `el` */}
onClick={() => {
props.click({ idx: idx(), el: el });
}}>
{el}
</li>
)}
</For>
</ul>
);
};

const App: Component = () => {
return (
<List>
<Child>el 1</Child>
<Child>el 2</Child>
<Child>el 3</Child>
</List>
);
};
interface event {
idx: number;
el: JSXElement;
}

const List: FlowComponent<{ click: Setter<event> }, JSXElement[]> = (props) => {
return (
<ul>
<For each={props.children}>
{(el, idx) => (
<li
style={'padding:2rem;border:1pt dashed violet;'}
{/* i want to pass trigger something in `el` */}
onClick={() => {
props.click({ idx: idx(), el: el });
}}>
{el}
</li>
)}
</For>
</ul>
);
};

const App: Component = () => {
return (
<List>
<Child>el 1</Child>
<Child>el 2</Child>
<Child>el 3</Child>
</List>
);
};
26 replies
SSolidJS
Created by bokuno_disk_cord on 1/5/2023 in #support
can i propagate event to child?
idk how to do it with this method.
26 replies
SSolidJS
Created by bokuno_disk_cord on 1/5/2023 in #support
can i propagate event to child?
oh, so i pass the accessor to the children and pass setter to the list?
26 replies
SSolidJS
Created by bokuno_disk_cord on 1/5/2023 in #support
can i propagate event to child?
i have the same thought, to use effect. but idk how to do so. because i dont have control over the children. how can i pass the accessor or click, to the children?
26 replies
SSolidJS
Created by bokuno_disk_cord on 1/5/2023 in #support
can i propagate event to child?
the item inside the li could be anything, from simple text to svg icon. each item may have different action. my current approach is to accept a callback that look like this.
type ItemClickCallback = (idx: number, el: JSX.Element) => void
type ItemClickCallback = (idx: number, el: JSX.Element) => void
the action dispatch/routing would be handled by the parent component.
26 replies
SSolidJS
Created by bokuno_disk_cord on 1/5/2023 in #support
can i propagate event to child?
So I have a list component (ul) what accept JSX.ArrayComponent as children. i want to be able to put anything to it as list item, like anchor element a or anything with onClick event attached to it. the problem is that the item container (li) is bigger than its child component. i want to be able to click on the container (not exactly at the text) and run an action.
26 replies
SSolidJS
Created by bokuno_disk_cord on 1/5/2023 in #support
can i propagate event to child?
or maybe my component could accept a callback? is that better?
26 replies
SSolidJS
Created by bokuno_disk_cord on 1/5/2023 in #support
can i propagate event to child?
i can just export a global variable. but doing so prevent me create multiple instance of the component.
26 replies