Trying to fetch data in-component because the data fetched is based on a prop. I can't seem to get the component to render to the page and I think it's due to the fact the data fetching is async and happening in-component.
Any idea how I can resolve this problem?
Data fetching needs to be based on framework component props, not astro props.
Here is example react/preact component:
const [data, setData] = useState(null);
const getPosts = useCallback(
async function getPosts() {
const data = await fetch(`...siteurl.../${category}`);
setData(data);
},
[category]
);
useEffect(() => {
getPosts().catch(console.error);
}, [getPosts])
... return ( data && data.map .....)
Thanks,
Isaac