Conceptual
Login

Provide and Inject

provide(key, value) in an ancestor makes a value available to inject(key) in any descendant regardless of depth, eliminating prop drilling; passing a ref keeps the injection reactive, and the convention is that only the provider mutates the value, ideally exposing mutation functions alongside readonly state.

This Concept is waiting for its first lesson!

provide(key, value) in an ancestor makes a value available to inject(key) in any descendant regardless of depth, eliminating prop drilling; passing a ref keeps the injection reactive, and the convention is that only the provider mutates the value, ideally exposing mutation functions alongside readonly state.

Are you a teacher? Sign in to start contributing.

Sign In