@momo-kits/tab-view 0.92.8-beta.10 → 0.92.8-beta.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.tsx CHANGED
@@ -30,6 +30,11 @@ const TabView: FC<TabViewProps> = ({
30
30
  const {theme} = useContext(ApplicationContext);
31
31
  const _onPressTabItem = (index: number) => {
32
32
  pagerRef.current?.setPage(index);
33
+
34
+ if (!lazy.includes(index)) {
35
+ lazy.push(index);
36
+ }
37
+
33
38
  onPressTabItem?.(index);
34
39
  setSelectedIndex(index);
35
40
  };
package/package.json CHANGED
@@ -1,17 +1,17 @@
1
1
  {
2
- "name": "@momo-kits/tab-view",
3
- "version": "0.92.8-beta.10",
4
- "private": false,
5
- "main": "index.tsx",
6
- "dependencies": {},
7
- "peerDependencies": {
8
- "@momo-kits/foundation": "latest",
9
- "prop-types": "^15.7.2",
10
- "react": "16.9.0",
11
- "react-native": ">=0.55"
12
- },
13
- "devDependencies": {
14
- "@momo-platform/versions": "4.1.11"
15
- },
16
- "license": "MoMo"
2
+ "name": "@momo-kits/tab-view",
3
+ "version": "0.92.8-beta.15",
4
+ "private": false,
5
+ "main": "index.tsx",
6
+ "dependencies": {},
7
+ "peerDependencies": {
8
+ "@momo-kits/foundation": "latest",
9
+ "prop-types": "^15.7.2",
10
+ "react": "16.9.0",
11
+ "react-native": ">=0.55"
12
+ },
13
+ "devDependencies": {
14
+ "@momo-platform/versions": "4.1.11"
15
+ },
16
+ "license": "MoMo"
17
17
  }
@@ -69,16 +69,14 @@ const CardTabBar: FC<TabBarProps> = ({
69
69
  },
70
70
  ]}>
71
71
  {!!tabs[selectedIndex]?.renderIcon &&
72
- !['string', 'boolean', 'number'].includes(
73
- typeof tabs[selectedIndex]?.renderIcon,
74
- ) && (
72
+ typeof tabs[selectedIndex]?.renderIcon === 'function' && (
75
73
  <View
76
74
  style={[
77
75
  styles.icon,
78
76
  styles.iconHolder,
79
77
  {marginRight: Spacing.XS},
80
78
  ]}>
81
- {tabs[selectedIndex]?.renderIcon}
79
+ {tabs[selectedIndex]?.renderIcon?.(true)}
82
80
  </View>
83
81
  )}
84
82
  {!tabs[selectedIndex]?.renderIcon && !!tabs[selectedIndex]?.icon && (
@@ -52,17 +52,12 @@ const TabItem: FC<TabItemProps> = ({
52
52
  },
53
53
  ]}
54
54
  onPress={onPressTabItem}>
55
- {renderIcon &&
56
- !['string', 'boolean', 'number'].includes(typeof renderIcon) && (
57
- <View
58
- style={[
59
- styles.icon,
60
- styles.iconHolder,
61
- {marginRight: Spacing.S},
62
- ]}>
63
- {renderIcon}
64
- </View>
65
- )}
55
+ {renderIcon && typeof renderIcon === 'function' && (
56
+ <View
57
+ style={[styles.icon, styles.iconHolder, {marginRight: Spacing.S}]}>
58
+ {renderIcon(active)}
59
+ </View>
60
+ )}
66
61
  {!renderIcon && !!icon && (
67
62
  <Icon
68
63
  style={[styles.icon, {marginRight: Spacing.S}]}
@@ -105,17 +100,16 @@ const TabItem: FC<TabItemProps> = ({
105
100
  ]}
106
101
  onPress={onPressTabItem}>
107
102
  <View>
108
- {renderIcon &&
109
- !['string', 'boolean', 'number'].includes(typeof renderIcon) && (
110
- <View
111
- style={[
112
- styles.icon,
113
- styles.iconHolder,
114
- {marginBottom: Spacing.XS},
115
- ]}>
116
- {renderIcon}
117
- </View>
118
- )}
103
+ {renderIcon && typeof renderIcon === 'function' && (
104
+ <View
105
+ style={[
106
+ styles.icon,
107
+ styles.iconHolder,
108
+ {marginBottom: Spacing.XS},
109
+ ]}>
110
+ {renderIcon(active)}
111
+ </View>
112
+ )}
119
113
  {!renderIcon && !!icon && (
120
114
  <Icon
121
115
  style={[
package/types.ts CHANGED
@@ -13,7 +13,7 @@ export type Tab = {
13
13
  */
14
14
  icon?: string;
15
15
 
16
- renderIcon?: ReactNode;
16
+ renderIcon?: (active: boolean) => ReactElement;
17
17
 
18
18
  /**
19
19
  * The main component or content to be displayed when this tab is active.