Circular dependency? Cannot access 'useUserStore' before initialization + HMR console errors #1941
-
|
Hi, Currently switching from We have encountered some issue when migrating the user store, problems seem to be:
Here is a minimalist repository showing that app crashes at startup 👉 https://github.com/cedric25/try-pinia-repro I've tried a few things: OptionAPI / CompositionAPI, Setup Stores / Option Store, mapState / storeToRefs... Stop using There is probably nothing to fix in pinia, I'm just looking for advice :)
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
|
Review the import structure of the files involved. Refactor your code to break the loop, perhaps by separating shared logic into a utility file that neither store depends on. |
Beta Was this translation helpful? Give feedback.
-
|
Hey, thanks for your answer 😀
Yes that's probably the easiest fix. |
Beta Was this translation helpful? Give feedback.
Review the import structure of the files involved. Refactor your code to break the loop, perhaps by separating shared logic into a utility file that neither store depends on.
For router configurations, use dynamic imports for components to ensure they are loaded lazily, only after Pinia is fully initialized.