-
-
Notifications
You must be signed in to change notification settings - Fork 92
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Typescript error when passing root prop to RecoilizeDebugger #138
Comments
Same problem here, any help please? |
Do you want to try it like this? const [root, setRoot] = useState<HTMLElement>();
const RecoilizeDebugger = dynamic(
() => {
return import('recoilize');
},
{ ssr: false },
);
useEffect(() => {
if (typeof window.document !== 'undefined') {
setRoot(document.getElementById('__next') as HTMLElement);
}
}, [root]); |
I fixed this error temporary. do typing in dyanmic const [root, setRoot] = useState<HTMLElement>()
const RecoilizeDebugger = dynamic<{root: HTMLElement | undefined}>(
() => import('recoilize'),
{ssr: false},
)
useEffect(() => {
if (typeof window.document !== 'undefined') {
setRoot(document.querySelector('#__next') as HTMLElement)
}
}, [root]) |
This issue occurs when the root is not defined and the RecoilateDebugger is running {root !== undefined && <RecoilizeDebugger root={root} />} const [root, setRoot] = useState<HTMLElement | undefined>();
const RecoilizeDebugger = dynamic<{ root: HTMLElement | undefined }>(() => import('recoilize'), {
ssr: false,
});
useEffect(() => {
if (typeof window.document !== 'undefined') {
setRoot(document.getElementById('__next') as HTMLElement);
}
}, [root]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Having problems setting up
Recoilize
in a Next.js app and typescript.I get:
Type '{ root: any; }' is not assignable to type 'IntrinsicAttributes & { children?: ReactNode; }'.
on this line:The problem seems to be we are initiating
root
asnull
in this line:Here is the complete code: https://gist.github.com/matiasmm/1d87a1221e14345b1153d296e25e4bbc#file-_app-tsx-L27
Is there a workaround for this?
The text was updated successfully, but these errors were encountered: