1
- import React , { useContext , useMemo } from 'react'
2
- import { StyleSheet , View , ViewProps , ViewStyle } from 'react-native'
3
- import { StyleProp } from 'react-native'
1
+ import { forwardRef , memo , useContext , useMemo } from 'react'
2
+ import { StyleSheet , View , type ViewProps , type ViewStyle } from 'react-native'
3
+ import { type StyleProp } from 'react-native'
4
4
import {
5
5
KeyboardAwareScrollView ,
6
- KeyboardAwareScrollViewProps ,
6
+ type KeyboardAwareScrollViewProps ,
7
7
} from 'react-native-keyboard-controller'
8
8
import Animated , {
9
- AnimatedScrollViewProps ,
9
+ type AnimatedScrollViewProps ,
10
10
useAnimatedProps ,
11
11
} from 'react-native-reanimated'
12
12
import { useSafeAreaInsets } from 'react-native-safe-area-context'
@@ -35,7 +35,7 @@ export type ScreenProps = React.ComponentProps<typeof View> & {
35
35
/**
36
36
* Outermost component of every screen
37
37
*/
38
- export const Screen = React . memo ( function Screen ( {
38
+ export const Screen = memo ( function Screen ( {
39
39
style,
40
40
noInsetTop,
41
41
...props
@@ -61,49 +61,55 @@ export type ContentProps = AnimatedScrollViewProps & {
61
61
/**
62
62
* Default scroll view for simple pages
63
63
*/
64
- export const Content = React . memo ( function Content ( {
65
- children,
66
- style,
67
- contentContainerStyle,
68
- ignoreTabletLayoutOffset,
69
- ...props
70
- } : ContentProps ) {
71
- const t = useTheme ( )
72
- const { footerHeight} = useShellLayout ( )
73
- const animatedProps = useAnimatedProps ( ( ) => {
74
- return {
75
- scrollIndicatorInsets : {
76
- bottom : footerHeight . get ( ) ,
77
- top : 0 ,
78
- right : 1 ,
79
- } ,
80
- } satisfies AnimatedScrollViewProps
81
- } )
64
+ export const Content = memo (
65
+ forwardRef < Animated . ScrollView , ContentProps > ( function Content (
66
+ {
67
+ children,
68
+ style,
69
+ contentContainerStyle,
70
+ ignoreTabletLayoutOffset,
71
+ ...props
72
+ } ,
73
+ ref ,
74
+ ) {
75
+ const t = useTheme ( )
76
+ const { footerHeight} = useShellLayout ( )
77
+ const animatedProps = useAnimatedProps ( ( ) => {
78
+ return {
79
+ scrollIndicatorInsets : {
80
+ bottom : footerHeight . get ( ) ,
81
+ top : 0 ,
82
+ right : 1 ,
83
+ } ,
84
+ } satisfies AnimatedScrollViewProps
85
+ } )
82
86
83
- return (
84
- < Animated . ScrollView
85
- id = "content"
86
- automaticallyAdjustsScrollIndicatorInsets = { false }
87
- indicatorStyle = { t . scheme === 'dark' ? 'white' : 'black' }
88
- // sets the scroll inset to the height of the footer
89
- animatedProps = { animatedProps }
90
- style = { [ scrollViewStyles . common , style ] }
91
- contentContainerStyle = { [
92
- scrollViewStyles . contentContainer ,
93
- contentContainerStyle ,
94
- ] }
95
- { ...props } >
96
- { isWeb ? (
97
- < Center ignoreTabletLayoutOffset = { ignoreTabletLayoutOffset } >
98
- { /* @ts -expect-error web only -esb */ }
99
- { children }
100
- </ Center >
101
- ) : (
102
- children
103
- ) }
104
- </ Animated . ScrollView >
105
- )
106
- } )
87
+ return (
88
+ < Animated . ScrollView
89
+ ref = { ref }
90
+ id = "content"
91
+ automaticallyAdjustsScrollIndicatorInsets = { false }
92
+ indicatorStyle = { t . scheme === 'dark' ? 'white' : 'black' }
93
+ // sets the scroll inset to the height of the footer
94
+ animatedProps = { animatedProps }
95
+ style = { [ scrollViewStyles . common , style ] }
96
+ contentContainerStyle = { [
97
+ scrollViewStyles . contentContainer ,
98
+ contentContainerStyle ,
99
+ ] }
100
+ { ...props } >
101
+ { isWeb ? (
102
+ < Center ignoreTabletLayoutOffset = { ignoreTabletLayoutOffset } >
103
+ { /* @ts -expect-error web only -esb */ }
104
+ { children }
105
+ </ Center >
106
+ ) : (
107
+ children
108
+ ) }
109
+ </ Animated . ScrollView >
110
+ )
111
+ } ) ,
112
+ )
107
113
108
114
const scrollViewStyles = StyleSheet . create ( {
109
115
common : {
@@ -124,7 +130,7 @@ export type KeyboardAwareContentProps = KeyboardAwareScrollViewProps & {
124
130
*
125
131
* BE SURE TO TEST THIS WHEN USING, it's untested as of writing this comment.
126
132
*/
127
- export const KeyboardAwareContent = React . memo ( function LayoutScrollView ( {
133
+ export const KeyboardAwareContent = memo ( function LayoutKeyboardAwareContent ( {
128
134
children,
129
135
style,
130
136
contentContainerStyle,
@@ -147,7 +153,7 @@ export const KeyboardAwareContent = React.memo(function LayoutScrollView({
147
153
/**
148
154
* Utility component to center content within the screen
149
155
*/
150
- export const Center = React . memo ( function LayoutContent ( {
156
+ export const Center = memo ( function LayoutCenter ( {
151
157
children,
152
158
style,
153
159
ignoreTabletLayoutOffset,
@@ -192,7 +198,7 @@ export const Center = React.memo(function LayoutContent({
192
198
/**
193
199
* Only used within `Layout.Screen`, not for reuse
194
200
*/
195
- const WebCenterBorders = React . memo ( function LayoutContent ( ) {
201
+ const WebCenterBorders = memo ( function LayoutWebCenterBorders ( ) {
196
202
const t = useTheme ( )
197
203
const { gtMobile} = useBreakpoints ( )
198
204
const { centerColumnOffset} = useLayoutBreakpoints ( )
0 commit comments