Delegated props.
The default props.
A context that carries delegated props.
// 1. Create a context
const MyPropsContext = createDelegatedPropsContext<{ foo: string }>();
// 2. Use the context in a component
function Bar() {
const delegatedProps = useContext(MyPropsContext.context);
// Use props here
return delegatedProps?.foo;
}
// 3. Render a provider and delegate props to descendants
<MyPropsContext.Provider value={{ foo: 'hello' }}>
<Bar />
</MyPropsContext.Provider>
Creates a context that merges delegated props.
If a provider is nested inside another provider of the same delegate context, it merges its props with the props from the enclosing provider.
Delegated props.
A context that carries delegated props.
// 1. Create a context
const MyPropsContext = createDelegatedPropsContext<{ foo: string }>();
// 2. Use the context in a component
function Bar() {
const delegatedProps = useContext(MyPropsContext.context);
// Use props here
return delegatedProps?.foo;
}
// 3. Render a provider and delegate props to descendants
<MyPropsContext.Provider value={{ foo: 'hello' }}>
<Bar />
</MyPropsContext.Provider>
Creates a context that merges delegated props.
If a provider is nested inside another provider of the same delegate context, it merges its props with the props from the enclosing provider.