I am learning how to use react-ketting
There are some examples of using it on the wiki
And in UseCollection section I am stuck
Could someone explain what is this and how it works:
function MyCollectionItem({resource}: { resource: Resource<Article> }) {
Full snippet is:
function MyCollection() {
const {
loading,
error,
items
} = useCollection<Article>('/articles');
if (loading) return <div>loading...</div>;
if (error) return <div class="error">boo</div>;
return <ul>{items.map(item => <MyCollectionItem resource={item} />)}</ul>
}
function MyCollectionItem({resource}: { resource: Resource<Article> }) {
const {
loading,
error,
data
} = useResource(resource);
if (loading) return <div>loading...</div>;
if (error) return <div className="error">boo</div>;
return <li>{data.title} - {data.body}</li>;
}
I want to add string prop to MyCollectionItem like
function MyCollectionItem({resource}: { resource: Resource<Article> }, anotherOption: string) {
And call it
<MyCollectionItem·resource={item}·anotherOption='project'·key={item.uri}·/>
Got error
[tsserver 2322] [E] Type '{ resource: Resource<Article>; anotherOption: string; key: string; }' is not assignable to type 'IntrinsicAttributes & { resource: Resource<Article>; }'. Property 'anotherOption' does not exist on type
IntrinsicAttributes & { resource: Resource<Article>; }'