Skip to content

"Avoid mutating a prop directly" warning when updating prop #631

Closed
@aphofstede

Description

@aphofstede

Version

1.0.0-beta.16

Reproduction link

https://codesandbox.io/s/vnv9wzp8rl

Steps to reproduce

See repro CodeSandbox.

  • Create a minimal component (HelloWorld)
  • Create another component (base component MobileCollapseRow) that takes two props, uses one of them and includes the minimal component
  • Create the final component (ContractRow) that uses the base component and passes it the prop used above, with a computed prop as value, based on its own prop
  • Now create a test that passes in a new value for the prop in the last component and observe the console.

What is expected?

Prop is updated and value changes without warnings

What is actually happening?

An warning is logged, complaining about changing a prop that isn't actually touched at all:

[Vue warn]: Avoid mutating a prop directly since the value will be overwritten whenever the parent component re-renders. Instead, use a data or computed property based on the prop's value. Prop being mutated: "actions"

found in

---> at src/components/MobileCollapseRow.vue


Note that the test in de CodeSandbox example does succeed, but keep an eye on the console tab.

Note that the warning complains about another prop! Something fishy is going on here..

Note: Removing the child component (HelloWorld) from the base component (MobileCollapseRow) makes the warning disappear.

Note: Removing the <a> where the prop is used from the base component makes the warning disappear.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions