`provide`/`inject` cascading nature documentation
Nobody has claimed this yet.
- Dominant language
- Vue
- Stars
- 3.2k
- Forks
- 5k
- Avg merge
- 14d 17h
- Merged PRs (30d)
- 1
Description
What problem does this feature solve?
When using provide multiple times in the component tree, the closes parent provides the value injected with inject. This means that if we have let's say a Menu component that provides some data and functionality and then in one of the MenuItems that uses this functionality we'll provide them again using the same injection key two things will happen:
- the child components will get the value provided by 2nd-level Menu
- for other components outside of that tree, the value will still be from the closes parent, so won't be overriden
This behavior is great for composing component tree from individual components that need to know about themselves. In the docs there's just the statement:
Providing reactive values allows the descendant components using the provided value to establish a reactive connection to the provider component.
I think it'd be great if the scoping nature of provide would be better explained, maybe with an example.
This is a purely documentation issue - everything works as expected code-wise.
What does the proposed API look like?
No changes
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start from the provide/inject documentation section referenced in the issue. Explain that the closest provider for an injection key is used by descendants while providers outside that subtree remain unaffected, and add an example showing nested Menu components. Done means the cascading and scoping behavior is clear without code changes.
Written by the indexing model from the issue text.
Assessment
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 38/100