Skip to content

Silence inject dev warning: injection not found #892

@vmihailenco

Description

@vmihailenco

What problem does this feature solve?

I am using provide/inject as component store and want to provide some value if it is not already provided by parent component, e.g.:

let v = inject(key)
if (!v) {
    provide(key, value)
}

It works well except that on first invocation there is a warning that injection not found.

What does the proposed API look like?

Remove the warning or provide some way to silence it or "declare" injection value without overriding existing one, e.g.:

inject(key, undefined) // undefined means set value if it does not already exist

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions