-
Notifications
You must be signed in to change notification settings - Fork 57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to expand wildcard path #53
Comments
Hmmm. I can't say why that's not working. Can you post in the Nuxt issues and see what comes up? |
I'm trying to replicate it with a clean, new nuxt app. |
I've created a new nuxt app and set up a simple store with the following structure:
And I'm trying to use it like this in my component
And this is the error I get:
Changing it to It works in version What could nuxt be doing that breaks this? |
OK, if you share the nuxt project I'll load it up and take a look. |
Is it related to this at all? Apparently Nuxt 2.x was doing some weird things. I didn't check, just trusted the contributor. |
Finally, I was able to look closer into this. There are tons of scenarios (nuxt in ssr mode, client mode, loading pathify as a client plugin, as aserver plugin, as a vuex plugin). I'll explain a simple and the most common case, assuming we are using If I try to e.g.
Then:
The first thing that comes to mind is to return TL;DR the problem is Nuxt trying to render the routes before initializing the store. Can somebody replicate a working scenario? In the meantime, the "solution" would be to avoid using wildcards. |
Going a step further, this seems to happen only when pathify is used in a layout or any component in a layout |
Bug report in nuxt's github nuxt/nuxt#5405 |
Hey, thanks for investigating! I know it's not fun when the codebase is not your own. Out of interest (and I assume you used the source) how did you find navigating around the source? Did it seem logical? |
I actually just put some breakpoints in the bundled script to find what's it doing, but I'm seeing the source now, and yes, I can say it's pretty well organized, I quickly found my way around. Ty for your time |
FYI, I found a really cool Chrome extension the other day called OctoLinker which adds live links to GitHub repos: It's great for this kind of thing! |
Looks great! Im going to give it a try, ty |
wildcard error still here |
Nuxt 2.6.1 ? |
Ah I see. So you mean with the VP 1.2.2 update, Nuxt still has its errors. You don't mean that Nuxt have released something, but it didn't fix it. |
Right : ) Even after reverting back to 2 version
it doesn't work |
I see this issue with just a vanilla https://github.com/yowzadave/vuex-pathify-test in the "HelloWorld.vue" component (https://github.com/yowzadave/vuex-pathify-test/blob/master/src/components/HelloWorld.vue), the wildcard |
I believe I'm having a related issue. The error happens if I import my router into a module file in any way. I suppose it's because the store theoretically isn't initialised in this file, it's just a file that exports one of the modules of the state. I don't (yet) do anything with the router... Just importing it causes the error. Is there any way to get it to work? My current workaround is to do the things in components that I would rather do in actions. Thanks. |
Hi @VesterDe, This is probably an order-of-import issue. As soon as you import your router file, webpack will then try to import everything that is included in that file, so you end up with a race condition because suddenly your components are being imported before the store they depend on. You'll have to think of a way to allow the store to finish its setup before using the router, or at least the routes and the dependent components it depends on. Consider adding routes dynamically, lazy-loading of routes or something like this:
Let me know how you get on :) |
Thanks for the feedback, it seemed like what you describe to me too. I've now solved it the way you recommended, although I'm not crazy about how it looks... I do prefer to handle the redirect inside actions though, so I'll keep it. For anyone wondering how exactly it looks for me, it's:
|
Another option would be moving all that code to a helper in the router folder, then you only need do: import { isLoggingIn } from '@plugins/router'
const actions = {
login () {
if(!isLoggingIn()) {
// your code
}
}
} Because Also, if you are doing everything with the URL, there's nothing to stop you parsing the URL directly with |
After upgrading a working project from nuxt 1.4 to 2.5 I'm getting this error
This is how I added pathify to the vuex plugins:
I'm using nuxt in spa mode
The text was updated successfully, but these errors were encountered: