This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { mutate } from 'swr' | |
function prefetch () { | |
mutate('/api/data', fetch('/api/data').then(res => res.json())) | |
// the second parameter is a Promise | |
// SWR will use the result when it resolves | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from "react"; | |
import { SWRConfig } from "swr"; | |
const App = () => { | |
return ( | |
<SWRConfig | |
value={{ | |
onError: (error, key) => { | |
if (error.status !== 403 && error.status !== 404) { | |
// We can send the error to Sentry, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { QueryClient, QueryClientProvider, useQuery } from 'react-query' | |
const queryClient = new QueryClient() | |
export default function App() { | |
return ( | |
<QueryClientProvider client={queryClient}> | |
<Example /> | |
</QueryClientProvider> | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React,{useState} from "react"; | |
import ReactDOM from "react-dom"; | |
import { QueryClient, QueryClientProvider, useQuery } from "react-query"; | |
import { ReactQueryDevtools } from "react-query/devtools"; | |
const queryClient = new QueryClient(); | |
export default function App() { | |
return ( | |
<QueryClientProvider client={queryClient}> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
{ | |
"name": "Google", | |
"url": "http:\/\/www.google.com" | |
}, | |
{ | |
"name": "Bing", | |
"url": "http:\/\/www.bing.com" | |
}, | |
{ |
OlderNewer