Skip to content

Instantly share code, notes, and snippets.

@austinroy
Created May 17, 2019 09:01
Show Gist options
  • Save austinroy/943ea1437787ec59bc9df35f399d02b1 to your computer and use it in GitHub Desktop.
Save austinroy/943ea1437787ec59bc9df35f399d02b1 to your computer and use it in GitHub Desktop.
Cached Supsense with react-cache
const getInfo = () => fetch("https://myApi.apiexample").then(res => res.json())
const ApiResource = createResource(getInfo)
const SayHello = () => {
const data = ApiResource.read()
return <div>Hi {data.name}</div>
}
const App = () => (
<Suspense fallback={<Spinner />}>
<SayHello />
</Suspense>
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment