Open
Description
Describe The Problem To Be Solved
The Context
primitive adds functionality to easily create context providers through createContextProvider
. Given the example code on the website, ...
const [CounterProvider, useCounter] = createContextProvider((props: { initial: number }) => {
const [count, setCount] = createSignal(props.initial);
const increment = () => setCount(count() + 1);
return { count, increment };
});
// Provide the context
<CounterProvider initial={1}>
<App />
</CounterProvider>;
... the following code does not work when paired with the MultiProvider
as it only accepts a single argument value
:
<MultiProvider
values={[
[CounterProvider, { initial: 1 }] // not working, as this is passed to the single `value` field.
]}
>
<App />
</MultiProvider>;
Suggest A Solution
It would be nice if the individual contexts of MultiProvider
accepted the same props as returned from createContextProvider
so they seamlessly work together. A workaround would be to wrap the context props with { value: ContextProps }
, but this destroys usability and requires refactoring the entire codebase
Metadata
Metadata
Assignees
Labels
No labels