When exporting molecule with custom scope from an npm package (i.e @my_packages/bunshi_test).
In an app that uses the npm package I get the error:
Cannot call use outside of a molecule function
the package code (@my_packages/bunshi_test):
import { molecule, createScope, use } from 'bunshi';
export const TestScope = createScope('none');
export const TestMolecule = molecule(
() => {
use(TestScope);
return 'test';
}
);
test app:
import { useMolecule, ScopeProvider } from 'bunshi/react';
import { TestScope, TestMolecule } from '@my_packages/bunshi_test';
const Test = () => {
const value = useMolecule(TestMolecule);
console.log('value:', value);
return null
}
const App = () => {
return (
<ScopeProvider scope={TestScope} value="graph1" >
<Test />
</ScopeProvider>
);
};
When exporting molecule with custom scope from an npm package (i.e @my_packages/bunshi_test).
In an app that uses the npm package I get the error:
Cannot call
useoutside of a molecule functionthe package code (@my_packages/bunshi_test):
test app: