Skip to content

Instantly share code, notes, and snippets.

@onosendi
Created December 30, 2021 15:49
Show Gist options
  • Save onosendi/9b09c6b20082f28288509c2d01cb7c9f to your computer and use it in GitHub Desktop.
Save onosendi/9b09c6b20082f28288509c2d01cb7c9f to your computer and use it in GitHub Desktop.
export default function Foo() {
const {
data,
setData,
} = useSomeContextHook();
useEffect(async () => {
const response = await api('/some/url');
setData(response);
}, []);
if (!data) {
return <p>No data</p>;
}
return data.map((item) => <p>{item.foo}</p>);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment