Skip to content

Instantly share code, notes, and snippets.

@matiasmm
Created May 3, 2021 13:12
Show Gist options
  • Save matiasmm/1d87a1221e14345b1153d296e25e4bbc to your computer and use it in GitHub Desktop.
Save matiasmm/1d87a1221e14345b1153d296e25e4bbc to your computer and use it in GitHub Desktop.
import * as React from "react"
import dynamic from 'next/dynamic';
import { RecoilRoot } from "recoil";
import "../styles/globals.css"
function MyApp({ Component, pageProps }): JSX.Element {
const [root, setRoot] = React.useState(null)
const RecoilizeDebugger = dynamic(
() => {
return import('recoilize');
},
{ ssr: false }
);
React.useEffect(() => {
if (typeof window.document !== 'undefined') {
setRoot(document.getElementById('__next'));
}
}, [root]);
return (
<RecoilRoot>
<RecoilizeDebugger root={root} /> // <- error here
<Component {...pageProps} />
</RecoilRoot>
)
}
export default MyApp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment