Not calling `getScope` in molecule definition results in shared atoms
I noticed that if I don't call the getScope function during the creation of a molecule the atoms end up being shared on useMolecule. I'm also using both the ScopeProvider and useMolecule(Molecule, { withScope: [Scope, value]}); syntax, if that is an issue.
Loving the library. Feel like this is solving a real issue with Jotai that should perhaps someday be in core.
Thanks @mutewinter, that is operating as intended. Calling getScope or getMolecule is what creates the dependency tree, similar to calling get in an atom.
Gotcha. Feels like there should be a warning / error if it’s not called — if possible.
I don't think it's possible to know a priori if a molecule should be scoped or not without that info. If you're using a global molecule (one without any calls to getMolecule or getScope) it is intended for it to be a singleton instance.
This could be better explained in the docs.
Yeah, docs makes sense. The examples re-using the molecule value to initialize an atom felt like a contrived example and not a real requirement.