-
My use case. I have a custom bunshi scope. I want to ensure when the molecules that depend on that scope are used, they are always used inside a ScopeProvider. In other words, I'd like to disable the global fallback for scope so that consumers of this molekule don't accidentally start using their state globally and interact with each other. is this possible? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
Answered my own question. const myScope = createScope<string | undefined>(undefined);
const myMolecule = molecule(() => {
const scope = use(myScope);
if (!scope) {
throw new Error("scope is undefined");
}
const countAtom = atom(0);
return {
countAtom: countAtom,
};
}); |
Beta Was this translation helpful? Give feedback.
-
Small follow up question: any ideas on how to ensure that all molecules within a given file folder use a scope? I want to make sure all the state within my folder's subtree is scoped to one particular custom scope and I feel like it will be easy for developers coming after me to create molecules and forget to add the |
Beta Was this translation helpful? Give feedback.
Answered my own question.