Bin
2025-12-17 d616898802dfe7e5dd648bcf53c6d1f86b6d3642
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import React from "react";
 
export const MultiProvider = (props) => {
  let content = props.children || null;
 
  /* Error/Validation */
  if (!props.providers) {
    throw "MultiProvider: Missing providers prop";
  }
 
  if (!props.children) {
    throw "MultiProvider: Missing children";
  }
 
  // Turn object into an array
  // const numberOfProviders = props.providers.size;
  const numberOfProviders = props.providers.length;
 
  if (!numberOfProviders) {
    // Providers prop is empty, r
    return content;
  }
 
  [...(props.providers ?? [])].reverse().forEach((provider) => {
    content = React.cloneElement(provider, null, content);
  });
 
  return content;
};