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.

TypeError: Cannot redefine property When back to same Component by VueRoute

See original GitHub issue

https://github.com/kaorun343/vue-property-decorator/blob/9aecbd28c53927494f51202c3682632bbeffb6ad/src/vue-property-decorator.ts#L106

vue-property-decorator@8.3.0

I have the problem when using the ProvideReactive with VueRouter always get the “TypeError: Cannot redefine property:” when back to the same Component at Second time

I am very sure the component is Destoryed at first time and I am not using the <keeplive /> or something else like that

maybe use the “hasOwnProperty” before defineProperty ?

if (
  !rv[reactiveInjectKey].hasOwnProperty(provide.managedReactive[i])
) {
  Object.defineProperty(
    rv[reactiveInjectKey],
    provide.managedReactive[i],
    {
      enumerable: true,
      get: function() {
        return _this[i];
      },
    },
  );
}

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6

github_iconTop GitHub Comments

3reactions
wowissucommented, Aug 25, 2020

Still broken in 8.4.x Same issue here, however I don’t get any “errors” it just doesn’t work. I use the route re-rendering right now, maybe this is why I dont get an error… But the Provide/Inject feature completely stops to work then. <router-view :key="$route.fullPath" All works fine with 8.2.2 for me.

still broken in 9.0.0 😦

but 8.2.2 works fine

https://github.com/kaorun343/vue-property-decorator/issues/277#issuecomment-558594655

Here is the solution. set inject: [] in Component options

3reactions
anoffcommented, Oct 30, 2019

Same here, configuration

export default class List extends Vue {
  @ProvideReactive() newChangeBlip: Blip

Edit: This issue happens in the latest v8.3.0, but works fine in v8.2.1 for now just fix it to that version to have something working 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Vuejs - Uncaught TypeError: Cannot redefine property: $router
Solved! In my index.html file, I had imported vue again: <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta name="viewport" ...
Read more >
[Solved]-Vue-Router returns "Cannot redefine property
Coding example for the question Vue-Router returns "Cannot redefine property: $router" error-Vue.js.
Read more >
TypeError: Cannot redefine property: $router - Vue Forum
... vue component package that uses vue router in abstract mode, i get an error saying: Reason: TypeError: Cannot redefine property: $router.
Read more >
FAQ - qiankun - UmiJS
Try to set the webpack output.library of the broken sub app the same with your ... Vue Router Error - Uncaught TypeError: Cannot...
Read more >
Possible reasons for " Cannot redefine property " Error ?
app.js:48343 Uncaught TypeError: Cannot redefine property: $router at Function ... components/dashboard.vue' // Router const router = new VueRouter({ routes ...
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