Hello !
I use the hook useCollection with an Hypermedia API (HAL) and i have problems with ketting cache.
I have an endpoint who returns a JSON like
{
_embedded: {
items: [
{{code: 'CODE_1}, links: {self: XXX}},
{{code: 'CODE_2}, links: {self: XXX}}
]
_links: {
self: 'api/test?from=XXX&to=XXX'
}
}
And i use useCollection like this :
const [state, setState] = useState([]);
const { items } = useCollection(
res.follow('collection', {
from: currentMonth.toISOString(),
to: currentMonth.toISOString(),
}),
{ rel: 'items', refreshOnStale: true }
);
useEffect(() => {
async function populateData() {
setState(await Promise.all(items.map((t) => t.get())));
}
populateData();
}, [items]);
return state.map((s) => <>s.code</>)
When I perform certain actions on another component, ketting cache of one item in the previous list is updated, but the component that call the useCollection doesn't refresh (and the s.code remains the same).
Did I misunderstand something?
Hello !
I use the hook useCollection with an Hypermedia API (HAL) and i have problems with ketting cache.
I have an endpoint who returns a JSON like
And i use useCollection like this :
When I perform certain actions on another component, ketting cache of one item in the previous list is updated, but the component that call the useCollection doesn't refresh (and the s.code remains the same).
Did I misunderstand something?