Closed
Description
Problem
Currently the props are merged with the instance's own data
, which has a few problems:
- Both data and props can declare the same property name. The order and priority of the merging is not clear. Should a prop overwrite the field with the same name in data? Or the other way around? Currently, the props' initial values are available inside
data
functions, but the same field returned in data gets overwritten by the prop. - Once merged, it's not clear whether a component property is its "private" state or a prop that is passed down from (and thus can be changed by) the parent, unless you go and check the component's props declaration.
Proposal
Move props into its own name space, for example this.props
. This avoids the merging problem (we can either make props
a reserved field or make it $props
) and makes it explicit that something is a prop that is obtained from outside the component.
Throw a warning if the user defines duplicate fields in data
and props
.
Metadata
Metadata
Assignees
Labels
No labels