Skip to content

Commit e23b911

Browse files
authored
Remove optimization attempt with react-freeze in TabController.TabPage (#1784)
1 parent a60dad6 commit e23b911

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

src/components/tabController/TabPage.tsx

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React, {PropsWithChildren, useCallback, useContext, useState, useMemo} from 'react';
22
import {StyleSheet} from 'react-native';
33
import Reanimated, {useAnimatedStyle, useAnimatedReaction, runOnJS} from 'react-native-reanimated';
4-
import {Freeze} from 'react-freeze';
4+
// import {Freeze} from 'react-freeze';
55
import TabBarContext from './TabBarContext';
66

77
export interface TabControllerPageProps {
@@ -40,7 +40,7 @@ export default function TabPage({
4040
}: PropsWithChildren<TabControllerPageProps>) {
4141
const {currentPage, asCarousel, containerWidth} = useContext(TabBarContext);
4242
const [shouldLoad, setLoaded] = useState(!lazy);
43-
const [focused, setFocused] = useState(false);
43+
// const [focused, setFocused] = useState(false);
4444

4545
const lazyLoad = useCallback(() => {
4646
if (lazy && !shouldLoad) {
@@ -51,22 +51,22 @@ export default function TabPage({
5151
useAnimatedReaction(() => {
5252
return currentPage.value;
5353
},
54-
(currentPage, previousPage) => {
54+
(currentPage/* , previousPage */) => {
5555
const isActive = currentPage === index;
56-
const wasActive = previousPage === index;
57-
const nearActive = asCarousel && (currentPage - 1 === index || currentPage + 1 === index);
58-
const wasNearActive =
59-
asCarousel && previousPage !== null && (previousPage - 1 === index || previousPage + 1 === index);
56+
// const wasActive = previousPage === index;
57+
// const nearActive = asCarousel && (currentPage - 1 === index || currentPage + 1 === index);
58+
// const wasNearActive =
59+
// asCarousel && previousPage !== null && (previousPage - 1 === index || previousPage + 1 === index);
6060

6161
if (isActive) {
6262
runOnJS(lazyLoad)();
6363
}
6464

65-
if (isActive || nearActive) {
66-
runOnJS(setFocused)(true);
67-
} else if (wasActive || wasNearActive) {
68-
runOnJS(setFocused)(false);
69-
}
65+
// if (isActive || nearActive) {
66+
// runOnJS(setFocused)(true);
67+
// } else if (wasActive || wasNearActive) {
68+
// runOnJS(setFocused)(false);
69+
// }
7070
},
7171
[currentPage]);
7272

@@ -85,8 +85,8 @@ export default function TabPage({
8585
return (
8686
<Reanimated.View style={style} testID={testID}>
8787
{!shouldLoad && renderLoading?.()}
88-
{/* {shouldLoad && props.children} */}
89-
<Freeze freeze={!shouldLoad || !focused}>{props.children}</Freeze>
88+
{shouldLoad && props.children}
89+
{/* <Freeze freeze={!shouldLoad || !focused}>{props.children}</Freeze> */}
9090
</Reanimated.View>
9191
);
9292
}

0 commit comments

Comments
 (0)