question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Vue Router example sandbox does not work

See original GitHub issue

Bug 🐞

What is the current behavior?

The code sandbox example that accompanies Combining with Vue Router is broken. The console displays errors stating:

TypeError: Cannot read property ‘query’ of undefined

This appears to stem from the stateMapping.stateToRoute method in Home.vue.

This seems to cause the products and URL to not update when a refinement filter is selected.

Make a sandbox with the current behavior

Sandbox: https://codesandbox.io/s/github/algolia/doc-code-samples/tree/master/Vue+InstantSearch/routing-vue-router

What is the expected behavior?

When I select a refinement, I should see the product grid update and see the query string added/updated in the URL.

What is the proposed solution?

It looks like this is using old versions of many dependencies (including 3.0.3 of vue-instantsearch). I think this example sandbox just needs updated and the routing object needs to be fixed so the refinement selections work as expected. It does seem like the routeToState method is expecting properties to be there that are not (e.g. query, even when I manually add a query string to the URL).

What is the version you are using?

This sandbox uses these dependencies:

  • algoliasearch: 3.33.0
  • instantsearch.css: 7.3.1
  • instatnsearch.js: 3.7.0
  • qs: 6.7.0
  • vue: 2.6.10
  • vue-instantsearch: 3.0.2
  • vue-router: 3.0.6

Updating these to their latest versions appear to have no affect. It seems like something is wrong with the actual code.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:11
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
calebanthonycommented, Dec 7, 2020

That’s what my edit does in my previous post. This sandbox fixes the problem: https://codesandbox.io/s/dreamy-tdd-3zzqn

And in creating my minimum reproducible example, I found my bug has to lie elsewhere in my application, because that example works.

1reaction
Haroenvcommented, Aug 21, 2020

ah yes, that’s right sorry! What I meant to say is compare the code of the history router and the custom Vue router, and use a code which is much closer to history (using window if available, use vue router just for getting the current URL / reading on server)

Read more comments on GitHub >

github_iconTop Results From Across the Web

vue-router examples - CodeSandbox
Learn how to use vue-router by viewing and forking example apps that make use of vue-router on CodeSandbox. Vue3The official Vue Cloud Sandbox...
Read more >
Am I missing something for vue router transitions?
However, the transition is not working at all. It correctly switches from component to component, but without transition. I've read the Vue and ......
Read more >
ScrollTrigger and Vue-router issue (start and stop bug) - GSAP
I made a sample in a sandbox project but I don't succeed to reproduce the error. Thank you for your help.
Read more >
Triggering events from Vue Router views - Dan Vega
The problem comes into play when you want to start triggering events from your views or even components within those views. In the...
Read more >
Tutorial: Vue.js for Beginners - Microsoft Learn
Try NodeJS with Visual Studio Code. If you don't already have it, install VS Code. We recommend installing VS Code on Windows, regardless...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found