Closed pgbradbury closed 2 years ago
Which react version are you using, 17.0.2 or 18 experimental?
"react": "^17.0.2", "recoil": "^0.6.1", "next": "^12.0.9",
I also use recoil in a Next application, have no such problems. To get to the bottom of it you should create a reproducer.
You can also look at the sources of the app to see how recoil gets integrated; just search the repository for recoil APIs.
Maybe it helps, here is the link https://github.com/project-millipede/millipede-docs
Thanks for the help,
I discovered the problem I think. I was using a hook (useSession) to assign a value in a selector that was being used as the default value of an atom. I am not sure why it would cause this behaviour rather than erroring saying I was using a hook outside a react component, very difficult to track down.
Paul.
I have created a basic atom in a separate file as such
I am then calling this atom in a next.js react component as such
When the page renders it does so twice and I get the following output and error
The
at n.Z (FilterIcp.jsx:20:25)
is the line above wheredropDown
is assigned. It is not clear why recoil is breaking. As you can see, on the first render the atom is assigned correctly, on the second render (when the page is hydrated again) it is not and breaks on a null object, however the atom is still there and correct. as seen by the console output from the logging.I have
<RecoilRoot>
in my_app.jsx