Skip to content

Provide/Inject in functional components  #5194

@alidcast

Description

@alidcast

I understand that functional components are instanceless, but given that they still have access to the parent context, wouldn't it make sense to also give them access to provided ancestor properties?

For example, I created vue-mobiledoc-editor. In the current version, I used a shared Vue instance that I passed to the editor and button components so that they could communicate with each other; and since there were various types of buttons (e.g. section, markup, and link buttons), I made the component functional.

I want to upgrade the code to using provide/inject since not having to pass the shared instance to every component makes the code more maintainable and will also make it easier to create multiple editor instances. However, it is not possible to inject exposed ancestor data and methods in functional components. If there is no specific reason for this, I'd like to make this a feature request.

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