ITADN

Use in a monorepo with hooks packages wrapping the store

#28Closedtyom 创建于 2024-08-27
T
tyomcommented
I have encountered an issue in a monorepo setup. I created a package with nanostore that has some logic including subscriptions to the atoms. I created another package which wraps the store into custom React hooks that I would like to export as an API to access the store data. However, the consumer app loses the atom subscriptions when used via custom hooks. But it works when the custom hook is created in the consumer app. Please see this [minimal reproducible example repo](https://github.com/tyom/nanostores-monorepo-issue). * Clone, run `pnpm install` and `pnpm start`; * Go to the app in the browser and open the console; * Observe how the two hooks affect the subscription. The first button increments the count within React component but does nothing for the subscription outside. The second button updates the count in both React component and the subscription outside of React (browser console). I assumed that the issue lies somewhere around the multiple version of the store being used but no matter what I tried with peer dependencies doesn't help.
关闭于 2026-03-14 5 条评论