1
1
import React , { PropsWithChildren , useCallback , useContext , useState , useMemo } from 'react' ;
2
2
import { StyleSheet } from 'react-native' ;
3
3
import Reanimated , { useAnimatedStyle , useAnimatedReaction , runOnJS } from 'react-native-reanimated' ;
4
- import { Freeze } from 'react-freeze' ;
4
+ // import {Freeze} from 'react-freeze';
5
5
import TabBarContext from './TabBarContext' ;
6
6
7
7
export interface TabControllerPageProps {
@@ -40,7 +40,7 @@ export default function TabPage({
40
40
} : PropsWithChildren < TabControllerPageProps > ) {
41
41
const { currentPage, asCarousel, containerWidth} = useContext ( TabBarContext ) ;
42
42
const [ shouldLoad , setLoaded ] = useState ( ! lazy ) ;
43
- const [ focused , setFocused ] = useState ( false ) ;
43
+ // const [focused, setFocused] = useState(false);
44
44
45
45
const lazyLoad = useCallback ( ( ) => {
46
46
if ( lazy && ! shouldLoad ) {
@@ -51,22 +51,22 @@ export default function TabPage({
51
51
useAnimatedReaction ( ( ) => {
52
52
return currentPage . value ;
53
53
} ,
54
- ( currentPage , previousPage ) => {
54
+ ( currentPage /* , previousPage */ ) => {
55
55
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);
60
60
61
61
if ( isActive ) {
62
62
runOnJS ( lazyLoad ) ( ) ;
63
63
}
64
64
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
+ // }
70
70
} ,
71
71
[ currentPage ] ) ;
72
72
@@ -85,8 +85,8 @@ export default function TabPage({
85
85
return (
86
86
< Reanimated . View style = { style } testID = { testID } >
87
87
{ ! 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> */ }
90
90
</ Reanimated . View >
91
91
) ;
92
92
}
0 commit comments