Skip to content

[opinion] i think you should use propsData instead of data  #66

@akhoury

Description

@akhoury

All the data being inserted into a Vue component is considered external or coming from outside or a parent of the component, hence, it should be considered as component.props and not as component.data

so, if props are used properly by each component definition, you can inject their values into a component instance via propsData

https://vuejs.org/v2/api/#propsData

I wasn't able to get this component to render, because it doesn't have a data() function, I know I can fix this simple component, but i do have a bunch of components that just accept props and i'd like to inject data into them.

<template>
  <p>Hi {{user && user.name}}</p>
</template>
<script>
  export default {
    props: ['user'],
  }
</script>

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions