react-native-tab-view 5.0.0-alpha.2 → 5.0.0-alpha.4

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.
@@ -4,16 +4,16 @@ export type Props<T extends Route> = TabDescriptor<T> & {
4
4
  position: Animated.AnimatedInterpolation<number>;
5
5
  route: T;
6
6
  navigationState: NavigationState<T>;
7
- activeColor?: ColorValue;
8
- inactiveColor?: ColorValue;
9
- pressColor?: ColorValue;
10
- pressOpacity?: number;
11
- onLayout?: (event: LayoutChangeEvent) => void;
7
+ activeColor?: ColorValue | undefined;
8
+ inactiveColor?: ColorValue | undefined;
9
+ pressColor?: ColorValue | undefined;
10
+ pressOpacity?: number | undefined;
11
+ onLayout?: ((event: LayoutChangeEvent) => void) | undefined;
12
12
  onPress: () => void;
13
13
  onLongPress: () => void;
14
- defaultTabWidth?: number;
14
+ defaultTabWidth?: number | undefined;
15
15
  style: StyleProp<ViewStyle>;
16
- android_ripple?: PressableAndroidRippleConfig;
16
+ android_ripple?: PressableAndroidRippleConfig | undefined;
17
17
  };
18
18
  export declare function TabBarItem<T extends Route>(props: Props<T>): import("react/jsx-runtime").JSX.Element;
19
19
  //# sourceMappingURL=TabBarItem.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"TabBarItem.d.ts","sourceRoot":"","sources":["../../../src/TabBarItem.tsx"],"names":[],"mappings":"AACA,OAAO,EACL,QAAQ,EACR,KAAK,UAAU,EACf,KAAK,iBAAiB,EAEtB,KAAK,4BAA4B,EACjC,KAAK,SAAS,EAGd,KAAK,SAAS,EACf,MAAM,cAAc,CAAC;AAKtB,OAAO,KAAK,EAAE,eAAe,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAErE,MAAM,MAAM,KAAK,CAAC,CAAC,SAAS,KAAK,IAAI,aAAa,CAAC,CAAC,CAAC,GAAG;IACtD,QAAQ,EAAE,QAAQ,CAAC,qBAAqB,CAAC,MAAM,CAAC,CAA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,UAAU,CAAC,EAAE,UAAU,GAAG,SAAS,CAAC;IACpC,YAAY,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAClC,QAAQ,CAAC,EAAE,CAAC,CAAC,KAAK,EAAE,iBAAiB,KAAK,IAAI,CAAC,GAAG,SAAS,CAAC;IAC5D,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,WAAW,EAAE,MAAM,IAAI,CAAC;IACxB,eAAe,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACrC,KAAK,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAC5B,cAAc,CAAC,EAAE,4BAA4B,GAAG,SAAS,CAAC;CAC3D,CAAC;AA+NF,wBAAgB,UAAU,CAAC,CAAC,SAAS,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,2CAsB1D"}
@@ -2,7 +2,7 @@ import React from 'react';
2
2
  import type { ColorValue, StyleProp, ViewStyle } from 'react-native';
3
3
  interface TabBarItemLabelProps {
4
4
  color: ColorValue;
5
- label?: string;
5
+ label?: string | undefined;
6
6
  style: StyleProp<ViewStyle>;
7
7
  icon: React.ReactNode;
8
8
  }
@@ -1 +1 @@
1
- {"version":3,"file":"TabBarItemLabel.d.ts","sourceRoot":"","sources":["../../../src/TabBarItemLabel.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAGrE,UAAU,oBAAoB;IAC5B,KAAK,EAAE,UAAU,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAC5B,IAAI,EAAE,KAAK,CAAC,SAAS,CAAC;CACvB;AAED,eAAO,MAAM,eAAe,4DACM,oBAAoB,oDAkBrD,CAAC"}
1
+ {"version":3,"file":"TabBarItemLabel.d.ts","sourceRoot":"","sources":["../../../src/TabBarItemLabel.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAGrE,UAAU,oBAAoB;IAC5B,KAAK,EAAE,UAAU,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,KAAK,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAC5B,IAAI,EAAE,KAAK,CAAC,SAAS,CAAC;CACvB;AAED,eAAO,MAAM,eAAe,4DACM,oBAAoB,oDAkBrD,CAAC"}
@@ -18,9 +18,9 @@ export type Props<T extends Route> = AdapterCommonProps & {
18
18
  *
19
19
  * Unlike `onIndexChange`, this is called regardless of whether the index changed or not.
20
20
  */
21
- onTabSelect?: (props: {
21
+ onTabSelect?: ((props: {
22
22
  index: number;
23
- }) => void;
23
+ }) => void) | undefined;
24
24
  /**
25
25
  * State for the tab view containing the current index and routes.
26
26
  *
@@ -40,16 +40,16 @@ export type Props<T extends Route> = AdapterCommonProps & {
40
40
  * Callback which returns a custom placeholder element.
41
41
  * The placeholder is shown when a scene is not yet loaded when `lazy` is enabled.
42
42
  */
43
- renderLazyPlaceholder?: (props: {
43
+ renderLazyPlaceholder?: ((props: {
44
44
  route: T;
45
- }) => React.ReactNode;
45
+ }) => React.ReactNode) | undefined;
46
46
  /**
47
47
  * Callback which returns a custom tab bar element to display.
48
48
  */
49
- renderTabBar?: (props: SceneRendererProps & EventEmitterProps & {
49
+ renderTabBar?: ((props: SceneRendererProps & EventEmitterProps & {
50
50
  navigationState: NavigationState<T>;
51
51
  options: Record<string, TabDescriptor<T>> | undefined;
52
- }) => React.ReactNode;
52
+ }) => React.ReactNode) | undefined;
53
53
  /**
54
54
  * Callback which returns a custom adapter to use for the tab view.
55
55
  * Adapters are responsible for handling gestures and animations between tabs.
@@ -61,12 +61,12 @@ export type Props<T extends Route> = AdapterCommonProps & {
61
61
  *
62
62
  * Defaults to `PagerViewAdapter` on Android and iOS, and `PanResponderAdapter` on other platforms.
63
63
  */
64
- renderAdapter?: (props: AdapterProps) => React.ReactElement;
64
+ renderAdapter?: ((props: AdapterProps) => React.ReactElement) | undefined;
65
65
  /**
66
66
  * Position of the tab bar in the tab view.
67
67
  * Defaults to `'top'`.
68
68
  */
69
- tabBarPosition?: 'top' | 'bottom';
69
+ tabBarPosition?: 'top' | 'bottom' | undefined;
70
70
  /**
71
71
  * Whether to lazily render the scenes.
72
72
  * When enabled, scenes are rendered only when they come into view.
@@ -76,27 +76,27 @@ export type Props<T extends Route> = AdapterCommonProps & {
76
76
  */
77
77
  lazy?: ((props: {
78
78
  route: T;
79
- }) => boolean) | boolean;
79
+ }) => boolean) | boolean | undefined;
80
80
  /**
81
81
  * How many screens to preload when `lazy` is enabled.
82
82
  *
83
83
  * Defaults to `0`.
84
84
  */
85
- lazyPreloadDistance?: number;
85
+ lazyPreloadDistance?: number | undefined;
86
86
  /**
87
87
  * The layout direction of the tab view.
88
88
  *
89
89
  * Defaults to the app's locale direction (RTL or LTR).
90
90
  */
91
- direction?: LocaleDirection;
91
+ direction?: LocaleDirection | undefined;
92
92
  /**
93
93
  * Style to apply to the pager container.
94
94
  */
95
- pagerStyle?: StyleProp<ViewStyle>;
95
+ pagerStyle?: StyleProp<ViewStyle> | undefined;
96
96
  /**
97
97
  * Style to apply to the tab view container.
98
98
  */
99
- style?: StyleProp<ViewStyle>;
99
+ style?: StyleProp<ViewStyle> | undefined;
100
100
  /**
101
101
  * Callback which returns a React element to render for each route.
102
102
  */
@@ -115,13 +115,13 @@ export type Props<T extends Route> = AdapterCommonProps & {
115
115
  *
116
116
  * These options are merged with `commonOptions`.
117
117
  */
118
- options?: Record<string, TabDescriptor<T>>;
118
+ options?: Record<string, TabDescriptor<T>> | undefined;
119
119
  /**
120
120
  * Options that apply to all tabs.
121
121
  *
122
122
  * Individual tab options from `options` will override these.
123
123
  */
124
- commonOptions?: TabDescriptor<T>;
124
+ commonOptions?: TabDescriptor<T> | undefined;
125
125
  };
126
126
  export declare function TabView<T extends Route>({ onIndexChange, onTabSelect, navigationState, renderScene, keyboardDismissMode, lazy, lazyPreloadDistance, onSwipeStart, onSwipeEnd, renderLazyPlaceholder, renderTabBar, renderAdapter, pagerStyle, style, direction, swipeEnabled, tabBarPosition, animationEnabled, options: sceneOptions, commonOptions, }: Props<T>): import("react/jsx-runtime").JSX.Element;
127
127
  //# sourceMappingURL=TabView.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"TabView.d.ts","sourceRoot":"","sources":["../../../src/TabView.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAGL,KAAK,SAAS,EAGd,KAAK,SAAS,EACf,MAAM,cAAc,CAAC;AAKtB,OAAO,KAAK,EACV,kBAAkB,EAClB,YAAY,EACZ,iBAAiB,EACjB,eAAe,EACf,eAAe,EACf,KAAK,EACL,kBAAkB,EAClB,aAAa,EACd,MAAM,SAAS,CAAC;AAEjB,MAAM,MAAM,KAAK,CAAC,CAAC,SAAS,KAAK,IAAI,kBAAkB,GAAG;IACxD;;;;;;;;OAQG;IACH,aAAa,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACvC;;;;;OAKG;IACH,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAC;IACjD;;;;;;;;;;;;;OAaG;IACH,eAAe,EAAE,eAAe,CAAC,CAAC,CAAC,CAAC;IACpC;;;OAGG;IACH,qBAAqB,CAAC,EAAE,CAAC,KAAK,EAAE;QAAE,KAAK,EAAE,CAAC,CAAA;KAAE,KAAK,KAAK,CAAC,SAAS,CAAC;IACjE;;OAEG;IACH,YAAY,CAAC,EAAE,CACb,KAAK,EAAE,kBAAkB,GACvB,iBAAiB,GAAG;QAClB,eAAe,EAAE,eAAe,CAAC,CAAC,CAAC,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EACnB,cAAsB,EACtB,gBAAuB,EACvB,OAAO,EAAE,YAAY,EACrB,aAAa,GACd,EAAE,KAAK,CAAC,CAAC,CAAC,2CAgGV"}
@@ -1,40 +1,40 @@
1
1
  import * as React from 'react';
2
2
  import type { Animated, ColorValue, StyleProp, TextStyle, ViewStyle } from 'react-native';
3
3
  export type TabDescriptor<T extends Route> = {
4
- accessibilityLabel?: string;
5
- accessible?: boolean;
6
- testID?: string;
7
- labelText?: string;
8
- labelAllowFontScaling?: boolean;
9
- href?: string;
10
- label?: (props: {
4
+ accessibilityLabel?: string | undefined;
5
+ accessible?: boolean | undefined;
6
+ testID?: string | undefined;
7
+ labelText?: string | undefined;
8
+ labelAllowFontScaling?: boolean | undefined;
9
+ href?: string | undefined;
10
+ label?: ((props: {
11
11
  route: T;
12
- labelText?: string;
12
+ labelText?: string | undefined;
13
13
  focused: boolean;
14
14
  color: ColorValue;
15
- allowFontScaling?: boolean;
16
- style?: StyleProp<TextStyle>;
17
- }) => React.ReactNode;
18
- labelStyle?: StyleProp<TextStyle>;
19
- icon?: (props: {
15
+ allowFontScaling?: boolean | undefined;
16
+ style?: StyleProp<TextStyle> | undefined;
17
+ }) => React.ReactNode) | undefined;
18
+ labelStyle?: StyleProp<TextStyle> | undefined;
19
+ icon?: ((props: {
20
20
  route: T;
21
21
  focused: boolean;
22
22
  color: ColorValue;
23
23
  size: number;
24
- }) => React.ReactNode;
25
- badge?: (props: {
24
+ }) => React.ReactNode) | undefined;
25
+ badge?: ((props: {
26
26
  route: T;
27
- }) => React.ReactElement;
28
- sceneStyle?: StyleProp<ViewStyle>;
27
+ }) => React.ReactElement) | undefined;
28
+ sceneStyle?: StyleProp<ViewStyle> | undefined;
29
29
  };
30
30
  export type LocaleDirection = 'ltr' | 'rtl';
31
31
  export type Route = {
32
32
  key: string;
33
- icon?: string;
34
- title?: string;
35
- accessible?: boolean;
36
- accessibilityLabel?: string;
37
- testID?: string;
33
+ icon?: string | undefined;
34
+ title?: string | undefined;
35
+ accessible?: boolean | undefined;
36
+ accessibilityLabel?: string | undefined;
37
+ testID?: string | undefined;
38
38
  };
39
39
  export type Event = {
40
40
  defaultPrevented: boolean;
@@ -69,35 +69,35 @@ export type AdapterCommonProps = {
69
69
  * - 'on-drag' - the keyboard is dismissed when a drag begins
70
70
  * - 'none' - drags and tab changes do not dismiss the keyboard
71
71
  */
72
- keyboardDismissMode?: 'none' | 'on-drag' | 'auto';
72
+ keyboardDismissMode?: 'none' | 'on-drag' | 'auto' | undefined;
73
73
  /**
74
74
  * Whether swiping between tabs is enabled.
75
75
  */
76
- swipeEnabled?: boolean;
76
+ swipeEnabled?: boolean | undefined;
77
77
  /**
78
78
  * Whether the tab switch animation is enabled.
79
79
  * If set to false, the tab switch will happen immediately without animation.
80
80
  */
81
- animationEnabled?: boolean;
81
+ animationEnabled?: boolean | undefined;
82
82
  /**
83
83
  * Callback that is called when the swipe gesture starts.
84
84
  */
85
- onSwipeStart?: () => void;
85
+ onSwipeStart?: (() => void) | undefined;
86
86
  /**
87
87
  * Callback that is called when the swipe gesture ends.
88
88
  */
89
- onSwipeEnd?: () => void;
89
+ onSwipeEnd?: (() => void) | undefined;
90
90
  /**
91
91
  * Callback that is called when a tab is selected.
92
92
  * This is called regardless of whether the index has changed or not.
93
93
  */
94
- onTabSelect?: (props: {
94
+ onTabSelect?: ((props: {
95
95
  index: number;
96
- }) => void;
96
+ }) => void) | undefined;
97
97
  /**
98
98
  * Style for the pager adapter.
99
99
  */
100
- style?: StyleProp<ViewStyle>;
100
+ style?: StyleProp<ViewStyle> | undefined;
101
101
  };
102
102
  export type AdapterRendererProps = {
103
103
  /**
@@ -112,7 +112,7 @@ export type AdapterRendererProps = {
112
112
  * The writing direction of the layout.
113
113
  * This can be 'ltr' or 'rtl' based on tab view's `direction` prop.
114
114
  */
115
- layoutDirection?: LocaleDirection;
115
+ layoutDirection?: LocaleDirection | undefined;
116
116
  /**
117
117
  * Render callback that should render the pages of the tab view.
118
118
  */
@@ -1 +1 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CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "react-native-tab-view",
3
3
  "description": "Tab view component for React Native",
4
- "version": "5.0.0-alpha.2",
4
+ "version": "5.0.0-alpha.4",
5
5
  "keywords": [
6
6
  "react-native-component",
7
7
  "react-component",
@@ -48,17 +48,17 @@
48
48
  },
49
49
  "devDependencies": {
50
50
  "@jest/globals": "^30.0.0",
51
- "@testing-library/react-native": "^13.2.1",
51
+ "@testing-library/react-native": "^13.3.3",
52
52
  "del-cli": "^6.0.0",
53
- "react": "19.1.0",
54
- "react-native": "0.81.4",
53
+ "react": "19.2.0",
54
+ "react-native": "0.83.2",
55
55
  "react-native-builder-bob": "^0.40.12",
56
56
  "react-native-pager-view": "^8.0.0",
57
- "react-test-renderer": "19.1.0",
57
+ "react-test-renderer": "19.2.0",
58
58
  "typescript": "^5.9.2"
59
59
  },
60
60
  "peerDependencies": {
61
- "react": ">= 19.0.0",
61
+ "react": ">= 19.2.0",
62
62
  "react-native": "*",
63
63
  "react-native-pager-view": ">= 7.0.0"
64
64
  },
@@ -80,5 +80,5 @@
80
80
  ]
81
81
  ]
82
82
  },
83
- "gitHead": "faad2ee23945a5a27090cfb837a35d1db25147ab"
83
+ "gitHead": "1f1525607d00eb924e466889ec0e703a3f5474b7"
84
84
  }
@@ -8,12 +8,16 @@ import {
8
8
  } from 'react-native';
9
9
 
10
10
  export type Props = Omit<PressableProps, 'onPress'> & {
11
- href?: string;
12
- pressColor?: ColorValue;
13
- pressOpacity?: number;
14
- onPress?: (
15
- e: React.MouseEvent<HTMLAnchorElement, MouseEvent> | GestureResponderEvent
16
- ) => void;
11
+ href?: string | undefined;
12
+ pressColor?: ColorValue | undefined;
13
+ pressOpacity?: number | undefined;
14
+ onPress?:
15
+ | ((
16
+ e:
17
+ | React.MouseEvent<HTMLAnchorElement, MouseEvent>
18
+ | GestureResponderEvent
19
+ ) => void)
20
+ | undefined;
17
21
  children: React.ReactNode;
18
22
  };
19
23
 
package/src/SceneView.tsx CHANGED
@@ -78,6 +78,8 @@ export function SceneView<T extends Route>({
78
78
  const ref = React.useRef<View>(null);
79
79
 
80
80
  React.useLayoutEffect(() => {
81
+ let unsubscribe: (() => void) | undefined;
82
+
81
83
  const element = ref.current;
82
84
 
83
85
  if (
@@ -91,8 +93,20 @@ export function SceneView<T extends Route>({
91
93
  } else {
92
94
  element.setAttribute('inert', '');
93
95
  }
96
+
97
+ // Remove inert as soon as the view is in viewport
98
+ // This will allow quick interaction after swiping
99
+ unsubscribe = subscribe((event) => {
100
+ if (event.type === 'enter' && event.index === index) {
101
+ element.removeAttribute('inert');
102
+ }
103
+ });
94
104
  }
95
- }, [isFocused]);
105
+
106
+ return () => {
107
+ unsubscribe?.();
108
+ };
109
+ }, [index, isFocused, subscribe]);
96
110
 
97
111
  return (
98
112
  <View ref={ref} aria-hidden={!isFocused} style={[styles.route, style]}>
package/src/TabBar.tsx CHANGED
@@ -13,9 +13,7 @@ import {
13
13
  StyleSheet,
14
14
  View,
15
15
  type ViewStyle,
16
- type ViewToken,
17
16
  } from 'react-native';
18
- import useLatestCallback from 'use-latest-callback';
19
17
 
20
18
  import {
21
19
  type Props as IndicatorProps,
@@ -38,28 +36,30 @@ import { useMeasureLayout } from './useMeasureLayout';
38
36
  export type Props<T extends Route> = SceneRendererProps &
39
37
  EventEmitterProps & {
40
38
  navigationState: NavigationState<T>;
41
- scrollEnabled?: boolean;
42
- bounces?: boolean;
43
- activeColor?: ColorValue;
44
- inactiveColor?: ColorValue;
45
- pressColor?: ColorValue;
46
- pressOpacity?: number;
47
- options?: Record<string, TabDescriptor<T>>;
48
- renderIndicator?: (props: IndicatorProps<T>) => React.ReactNode;
49
- renderTabBarItem?: (
50
- props: TabBarItemProps<T> & { key: string }
51
- ) => React.ReactElement;
52
- onTabPress?: (scene: Scene<T> & Event) => void;
53
- onTabLongPress?: (scene: Scene<T>) => void;
54
- tabStyle?: StyleProp<ViewStyle>;
55
- indicatorStyle?: StyleProp<ViewStyle>;
56
- indicatorContainerStyle?: StyleProp<ViewStyle>;
57
- contentContainerStyle?: StyleProp<ViewStyle>;
58
- style?: StyleProp<ViewStyle>;
59
- direction?: LocaleDirection;
60
- gap?: number;
61
- testID?: string;
62
- android_ripple?: PressableAndroidRippleConfig;
39
+ scrollEnabled?: boolean | undefined;
40
+ bounces?: boolean | undefined;
41
+ activeColor?: ColorValue | undefined;
42
+ inactiveColor?: ColorValue | undefined;
43
+ pressColor?: ColorValue | undefined;
44
+ pressOpacity?: number | undefined;
45
+ options?: Record<string, TabDescriptor<T>> | undefined;
46
+ renderIndicator?:
47
+ | ((props: IndicatorProps<T>) => React.ReactNode)
48
+ | undefined;
49
+ renderTabBarItem?:
50
+ | ((props: TabBarItemProps<T> & { key: string }) => React.ReactElement)
51
+ | undefined;
52
+ onTabPress?: ((scene: Scene<T> & Event) => void) | undefined;
53
+ onTabLongPress?: ((scene: Scene<T>) => void) | undefined;
54
+ tabStyle?: StyleProp<ViewStyle> | undefined;
55
+ indicatorStyle?: StyleProp<ViewStyle> | undefined;
56
+ indicatorContainerStyle?: StyleProp<ViewStyle> | undefined;
57
+ contentContainerStyle?: StyleProp<ViewStyle> | undefined;
58
+ style?: StyleProp<ViewStyle> | undefined;
59
+ direction?: LocaleDirection | undefined;
60
+ gap?: number | undefined;
61
+ testID?: string | undefined;
62
+ android_ripple?: PressableAndroidRippleConfig | undefined;
63
63
  };
64
64
 
65
65
  type CalculationOptions = {
@@ -368,7 +368,6 @@ export function TabBar<T extends Route>({
368
368
  const flatListRef = React.useRef<FlatList | null>(null);
369
369
  const isFirst = React.useRef(true);
370
370
  const scrollAmount = useAnimatedValue(0);
371
- const measuredTabWidths = React.useRef<Record<string, number>>({});
372
371
  const { routes } = navigationState;
373
372
  const flattenedTabWidth = getFlattenedTabWidth(tabStyle);
374
373
  const isWidthDynamic = flattenedTabWidth === 'auto';
@@ -440,6 +439,10 @@ export function TabBar<T extends Route>({
440
439
  [direction, layout.width, scrollAmount, tabBarWidth]
441
440
  );
442
441
 
442
+ const measuredTabWidths = React.useRef<Record<string, number>>({});
443
+ const animationFrameHandle =
444
+ React.useRef<ReturnType<typeof requestAnimationFrame>>(null);
445
+
443
446
  const renderItem = React.useCallback(
444
447
  ({ item: route, index }: ListRenderItemInfo<T>) => {
445
448
  const {
@@ -454,28 +457,13 @@ export function TabBar<T extends Route>({
454
457
  ? (e: LayoutChangeEvent) => {
455
458
  measuredTabWidths.current[route.key] = e.nativeEvent.layout.width;
456
459
 
457
- // When we have measured widths for all of the tabs, we should updates the state
458
- // We avoid doing separate setState for each layout since it triggers multiple renders and slows down app
459
- // If we have more than 10 routes divide updating tabWidths into multiple batches. Here we update only first batch of 10 items.
460
- if (
461
- routes.length > MEASURE_PER_BATCH &&
462
- index === MEASURE_PER_BATCH &&
463
- routes
464
- .slice(0, MEASURE_PER_BATCH)
465
- .every(
466
- (r) => typeof measuredTabWidths.current[r.key] === 'number'
467
- )
468
- ) {
469
- setTabWidths({ ...measuredTabWidths.current });
470
- } else if (
471
- routes.every(
472
- (r) => typeof measuredTabWidths.current[r.key] === 'number'
473
- )
474
- ) {
475
- // When we have measured widths for all of the tabs, we should updates the state
476
- // We avoid doing separate setState for each layout since it triggers multiple renders and slows down app
477
- setTabWidths({ ...measuredTabWidths.current });
460
+ if (animationFrameHandle.current != null) {
461
+ cancelAnimationFrame(animationFrameHandle.current);
478
462
  }
463
+
464
+ animationFrameHandle.current = requestAnimationFrame(() => {
465
+ setTabWidths({ ...measuredTabWidths.current });
466
+ });
479
467
  }
480
468
  : undefined;
481
469
 
@@ -598,25 +586,6 @@ export function TabBar<T extends Route>({
598
586
  [scrollAmount]
599
587
  );
600
588
 
601
- const handleViewableItemsChanged = useLatestCallback(
602
- ({ changed }: { changed: ViewToken[] }) => {
603
- if (routes.length <= MEASURE_PER_BATCH) {
604
- return;
605
- }
606
- // Get next vievable item
607
- const item = changed[changed.length - 1];
608
- const index = item?.index || 0;
609
- if (
610
- item.isViewable &&
611
- (index % 10 === 0 ||
612
- index === navigationState.index ||
613
- index === routes.length - 1)
614
- ) {
615
- setTabWidths({ ...measuredTabWidths.current });
616
- }
617
- }
618
- );
619
-
620
589
  return (
621
590
  <Animated.View
622
591
  ref={containerRef}
@@ -671,7 +640,6 @@ export function TabBar<T extends Route>({
671
640
  scrollEnabled={scrollEnabled}
672
641
  bounces={bounces}
673
642
  initialNumToRender={MEASURE_PER_BATCH}
674
- onViewableItemsChanged={handleViewableItemsChanged}
675
643
  alwaysBounceHorizontal={false}
676
644
  scrollsToTop={false}
677
645
  showsHorizontalScrollIndicator={false}