Skip to content

Commit 9e9f83c

Browse files
authored
Avoid block TabBarItem re-onLayout callback (#1869)
1 parent 538599b commit 9e9f83c

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/components/tabController/TabBarItem.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ export default function TabBarItem({
132132
const sharedSelectedLabelStyle = useSharedValue(JSON.parse(JSON.stringify(selectedLabelStyle)));
133133

134134
useEffect(() => {
135-
if (itemWidth.current) {
135+
if (props.width) {
136136
props.onLayout?.({nativeEvent: {layout: {x: 0, y: 0, width: itemWidth.current, height: 0}}} as LayoutChangeEvent,
137137
index);
138138
}
@@ -149,7 +149,7 @@ export default function TabBarItem({
149149
const onLayout = useCallback((event: LayoutChangeEvent) => {
150150
const {width} = event.nativeEvent.layout;
151151

152-
if (!itemWidth.current && itemRef?.current) {
152+
if (!props.width && itemRef?.current) {
153153
itemWidth.current = width;
154154
// @ts-ignore
155155
itemRef.current?.setNativeProps({style: {width, paddingHorizontal: null, flex: null}});

0 commit comments

Comments
 (0)