@buoyant roost sorry for the question on an existing thread but it looks like you might have answered a question for a problem that I'm trying to figure out when using Resource.
I have a "List" component that is "just" a wrapper where I'm using Resourceto request some data and that data is passed as props to a child component.
I have used the code example from the docs [https://qwik.builder.io/tutorial/reactivity/resource/]
I tried 2 approaches (both work)
1st - I pass everything as a single to the child component
2nd - I pass each prop separately
The problem is that in both cases there are TS type problems
<Resource
value={worksResource}
onPending={() => <>Loading...</>}
onRejected={(error) => <>Error: {error.message}</>}
onResolved={(works) => (
<section class="list">
{works.map((work) => (
// 1st approach
// <Item key={index} work={work} />
// 2nd approach
<Item
key={work.id}
id={work.id}
client={work.client}
project={work.project}
slug={work.slug}
image={work.image}
/>
))}
</section>
)}
/>
On 1st approach
Type 'string' is not assignable to type 'IWork'
The IWork is the interface I have on the child component
interface IWork {
id: string | number;
client: string;
project: string;
slug: string;
image: string;
}
On 2nd approach, it complains about each one of the props
Property 'id' does not exist on type 'string'
Property 'client' does not exist on type 'string'
Property 'project' does not exist on type 'string'
Property 'image' does not exist on type 'string'
What am I doing wrong?
Is this because of the serialization as it handles the props as strings?
Thanks