Created
October 17, 2022 13:39
-
-
Save trickydisco78/75c7160dc825937ba3c94bb3526a9f3d to your computer and use it in GitHub Desktop.
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 { ReactQueryCacheProvider, QueryCache } from 'react-query' | |
import { CSSReset } from '@chakra-ui/core' | |
import GlobalStyles from '../styles/global' | |
import { ReactQueryDevtools } from 'react-query-devtools' | |
const ReactQueryDevtoolsProd = React.lazy(() => | |
import('react-query-devtools/dist/react-query-devtools.production.min.js').then(devtools => ({ | |
default: devtools.ReactQueryDevtoolsProd, | |
})) | |
) | |
const explicitlyEnabled = | |
window.location.search.includes('dev-tools=true') || window.localStorage.getItem('dev-tools') === 'true' | |
const queryCache = new QueryCache({ | |
defaultConfig: { | |
queries: { | |
refetchOnWindowFocus: false, | |
}, | |
}, | |
}) | |
const Providers = ({ children }) => { | |
return ( | |
<ReactQueryCacheProvider queryCache={queryCache}> | |
<CSSReset /> | |
<GlobalStyles /> | |
<ReactQueryDevtools initialIsOpen /> | |
{explicitlyEnabled ? ( | |
<React.Suspense fallback={null}> | |
<ReactQueryDevtoolsProd initialIsOpen /> | |
</React.Suspense> | |
) : null} | |
{children} | |
</ReactQueryCacheProvider> | |
) | |
} | |
export default Providers |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment