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.

Error when using @ProvideReactive: Cannot redefine property

See original GitHub issue

When I upgrade vue-property-decorator to 8.3.0, it comes with a TypeError: Cannot redefine property on line Object.defineProperty(rv[reactiveInjectKey], provide.managedReactive[i], {. I think it was related to #249 and caused by #264 .

const InjectKey = Symbol();

@Component
class ParentComponent extends Vue {
    @ProvideReactive(InejctKey) foo: any = {};
}

@Component
class ChildComponent extends Vue {
    @InjectReactive({
        from: InejctKey,
        default: ({})
    })
    readonly foo!: any;
}

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:14
  • Comments:20 (1 by maintainers)

github_iconTop GitHub Comments

26reactions
Mrminfivecommented, Nov 26, 2019

set inject: [] in Component options

const InjectKey = Symbol();

@Component({ inject: [] })
class ParentComponent extends Vue {
    @ProvideReactive(InejctKey) foo: any = {};
}

@Component
class ChildComponent extends Vue {
    @InjectReactive({
        from: InejctKey,
        default: ({})
    })
    readonly foo!: any;
}

because

// inject parent reactive services (if any)
if (!Array.isArray(componentOptions.inject)) {
    componentOptions.inject = componentOptions.inject || {};
    componentOptions.inject[reactiveInjectKey] = { from: reactiveInjectKey, default: {}};
}
5reactions
fluidsoniccommented, Nov 5, 2019

I just ran into the same issue. When a second instance of a component that uses @ProvideReactive is being created TypeError: Cannot redefine property is thrown.

Downgrading to 8.2.2 fixes the issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error when using @ProvideReactive: Cannot redefine property
When I upgrade vue-property-decorator to 8.3.0, it comes with a TypeError: Cannot redefine property on line Object.defineProperty(rv[reactiveInjectKey] ...
Read more >
Support for SPAs / error when reloading (quick fix!) - Web
I have it destroying/unloading the ZoomMtg object when the user navigates away, but when they navigate back again, there are some issues with...
Read more >
InertiaJS with Laravel & Vue2: Cannot redefine property: $inertia
I'm using Vue2 and Laravel 8. I can't find anyone with the same issues anywhere. The error claims that 'App' is no longer...
Read more >
Provide/Inject API With Vue 3 - This Dot Labs
Why are we passing a computed property? By default, the provided value is not reactive. If we just wrote provide('username', state.name) , any ......
Read more >
vue-property-decorator - npm
property decorators for Vue Component. Latest version: 9.1.2, last published: 2 years ago. Start using vue-property-decorator in your ...
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