@@ -10,6 +10,20 @@ export function useBentoConfig() {
10
10
return useContext ( BentoConfigContext ) ;
11
11
}
12
12
13
+ export const deepmerge = deepmergeCustom ( {
14
+ mergeRecords : ( value , utils ) => {
15
+ // NOTE(vince): in case of a JSX.Element in the config (like the Navigation's activeVisualElement),
16
+ // we don't want to merge the props of the two elements, but we want to take just the second element instead.
17
+ if ( React . isValidElement ( value [ 0 ] ) || React . isValidElement ( value [ 1 ] ) ) {
18
+ return value [ 1 ] ;
19
+ }
20
+ return utils . actions . defaultMerge ;
21
+ } ,
22
+ // NOTE(fede): in case of an array in the config (like AreaLoader's dots),
23
+ // we don't want to merge the two arrays, but we want to take just the second one instead.
24
+ mergeArrays : ( value ) => value [ 1 ] ,
25
+ } ) ;
26
+
13
27
export function BentoConfigProvider ( {
14
28
value : config ,
15
29
children,
@@ -23,17 +37,6 @@ export function BentoConfigProvider({
23
37
// in case this is the top level provider.
24
38
const parentConfig = useBentoConfig ( ) ;
25
39
26
- const deepmerge = deepmergeCustom ( {
27
- mergeRecords : ( value , utils ) => {
28
- // NOTE(vince): in case of a JSX.Element in the config (like the Navigation's activeVisualElement),
29
- // we don't want to merge the props of the two elements, but we want to take just the second element instead.
30
- if ( React . isValidElement ( value [ 0 ] ) || React . isValidElement ( value [ 1 ] ) ) {
31
- return value [ 1 ] ;
32
- }
33
- return utils . actions . defaultMerge ;
34
- } ,
35
- } ) ;
36
-
37
40
return (
38
41
< BentoConfigContext . Provider value = { deepmerge ( parentConfig , config ) as BentoConfig } >
39
42
{ children }
0 commit comments