refactor: allow multiple providers
This commit is contained in:
parent
97d90ee809
commit
913dc9786c
|
@ -15,12 +15,17 @@ export default {
|
|||
),
|
||||
);
|
||||
const Providers = await latus.invokeOrdered('@latus/react/providers');
|
||||
const FlattenedProviders = [];
|
||||
for (let i = 0; i < Providers.length; i++) {
|
||||
const Provider = Providers[i];
|
||||
FlattenedProviders.push(...(Array.isArray(Provider[0]) ? Provider : [Provider]));
|
||||
}
|
||||
const RootComponent = () => {
|
||||
const children = Object.entries(Components)
|
||||
.map(([key, Component]) => React.createElement(Component, {key}));
|
||||
const RootElements = [
|
||||
[LatusContext.Provider, {value: latus}],
|
||||
].concat(Providers)
|
||||
].concat(FlattenedProviders)
|
||||
.reverse()
|
||||
.reduce((children, [Provider, props], i) => [
|
||||
// eslint-disable-next-line react/no-array-index-key
|
||||
|
|
Loading…
Reference in New Issue
Block a user