Skip to content

Commit 5f3a9d5

Browse files
fix issue of components reference
1 parent ab4eab2 commit 5f3a9d5

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

src/useDynamicTabs/useDynamicTabs.js

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@ import React, {useState, useReducer, useLayoutEffect, useRef} from 'react';
33
function useDynamicTabs(getDeps, options = {}, modules) {
44
const {reducer, getApiInstance, ApiContext, StateContext, ForceUpdateContext, Components} = getDeps();
55
const ref = useRef(null);
6-
if (ref.current === null)
7-
ref.current = {api: getApiInstance(options, modules, Components), TabListComponent: null, PanelListComponent: null};
6+
if (ref.current === null) {
7+
ref.current = {Components: {...Components}, TabListComponent: null, PanelListComponent: null};
8+
ref.current.api = getApiInstance(options, modules, ref.current.Components);
9+
}
810
const {
911
current: {api},
1012
} = ref,
@@ -44,14 +46,14 @@ function useDynamicTabs(getDeps, options = {}, modules) {
4446
<ApiContext.Provider value={api}>
4547
<StateContext.Provider value={api.stateRef}>
4648
<ForceUpdateContext.Provider value={api.forceUpdateState}>
47-
<Components.TablistView>
48-
<Components.TablistContainer>
49-
<Components.TablistOverflow>
50-
<Components.TabList {...props}></Components.TabList>
51-
</Components.TablistOverflow>
52-
</Components.TablistContainer>
49+
<_ref.Components.TablistView>
50+
<_ref.Components.TablistContainer>
51+
<_ref.Components.TablistOverflow>
52+
<_ref.Components.TabList {...props}></_ref.Components.TabList>
53+
</_ref.Components.TablistOverflow>
54+
</_ref.Components.TablistContainer>
5355
{props.children}
54-
</Components.TablistView>
56+
</_ref.Components.TablistView>
5557
</ForceUpdateContext.Provider>
5658
</StateContext.Provider>
5759
</ApiContext.Provider>

0 commit comments

Comments
 (0)