Skip to content

Commit 805bc69

Browse files
authored
bump dev dependencies and React Native used for lint (#5225)
1 parent cda678c commit 805bc69

39 files changed

Lines changed: 559 additions & 521 deletions

‎docs/animated.md‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,8 @@ For example, when working with horizontal scrolling gestures, you would do the f
192192
x: scrollX
193193
}
194194
}
195-
}]
195+
}],
196+
{useNativeEvent: true}
196197
)}
197198
```
198199

‎docs/animatedvaluexy.md‎

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,16 @@ const DraggableView = () => {
1717
1818
const panResponder = PanResponder.create({
1919
onStartShouldSetPanResponder: () => true,
20-
onPanResponderMove: Animated.event([
21-
null,
22-
{
23-
dx: pan.x, // x,y are Animated.Value
24-
dy: pan.y,
25-
},
26-
]),
20+
onPanResponderMove: Animated.event(
21+
[
22+
null,
23+
{
24+
dx: pan.x, // x,y are Animated.Value
25+
dy: pan.y,
26+
},
27+
],
28+
{useNativeDriver: false},
29+
),
2730
onPanResponderRelease: () => {
2831
Animated.spring(
2932
pan, // Auto-multiplexed

‎docs/animations.md‎

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -293,15 +293,15 @@ Gestures, like panning or scrolling, and other events can map directly to animat
293293
For example, when working with horizontal scrolling gestures, you would do the following in order to map `event.nativeEvent.contentOffset.x` to `scrollX` (an `Animated.Value`):
294294

295295
```tsx
296-
onScroll={Animated.event(
297-
// scrollX = e.nativeEvent.contentOffset.x
298-
[{nativeEvent: {
299-
contentOffset: {
300-
x: scrollX
301-
}
302-
}
303-
}]
304-
)}
296+
onScroll={Animated.event(
297+
// scrollX = e.nativeEvent.contentOffset.x
298+
[{
299+
nativeEvent: {
300+
contentOffset: { x: scrollX }
301+
}
302+
}],
303+
{useNativeDriver: true}
304+
)}
305305
```
306306

307307
The following example implements a horizontal scrolling carousel where the scroll position indicators are animated using the `Animated.event` used in the `ScrollView`
@@ -338,15 +338,18 @@ const App = () => {
338338
horizontal={true}
339339
pagingEnabled
340340
showsHorizontalScrollIndicator={false}
341-
onScroll={Animated.event([
342-
{
343-
nativeEvent: {
344-
contentOffset: {
345-
x: scrollX,
341+
onScroll={Animated.event(
342+
[
343+
{
344+
nativeEvent: {
345+
contentOffset: {
346+
x: scrollX,
347+
},
346348
},
347349
},
348-
},
349-
])}
350+
],
351+
{useNativeDriver: true},
352+
)}
350353
scrollEventThrottle={1}>
351354
{images.map((image, imageIndex) => {
352355
return (
@@ -459,7 +462,9 @@ const App = () => {
459462
const panResponder = useRef(
460463
PanResponder.create({
461464
onMoveShouldSetPanResponder: () => true,
462-
onPanResponderMove: Animated.event([null, {dx: pan.x, dy: pan.y}]),
465+
onPanResponderMove: Animated.event([null, {dx: pan.x, dy: pan.y}], {
466+
useNativeDriver: false,
467+
}),
463468
onPanResponderRelease: () => {
464469
Animated.spring(pan, {
465470
toValue: {x: 0, y: 0},

‎docs/appstate.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ const AppStateExample = () => {
3939
useEffect(() => {
4040
const subscription = AppState.addEventListener('change', nextAppState => {
4141
if (
42-
appState.current.match(/inactive|background/) &&
42+
appState.current?.match(/inactive|background/) &&
4343
nextAppState === 'active'
4444
) {
4545
console.log('App has come to the foreground!');

‎docs/dimensions.md‎

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,14 @@ If you are targeting foldable devices or devices which can change the screen siz
2626

2727
## Example
2828

29-
```SnackPlayer name=Dimensions%20Example
29+
```SnackPlayer name=Dimensions%20Example&ext=tsx
3030
import {useState, useEffect} from 'react';
31-
import {StyleSheet, Text, Dimensions} from 'react-native';
31+
import {
32+
StyleSheet,
33+
Text,
34+
Dimensions,
35+
type DimensionsPayload,
36+
} from 'react-native';
3237
import {SafeAreaView, SafeAreaProvider} from 'react-native-safe-area-context';
3338
3439
const windowDimensions = Dimensions.get('window');
@@ -43,8 +48,10 @@ const App = () => {
4348
useEffect(() => {
4449
const subscription = Dimensions.addEventListener(
4550
'change',
46-
({window, screen}) => {
47-
setDimensions({window, screen});
51+
({window, screen}: DimensionsPayload) => {
52+
if (window && screen) {
53+
setDimensions({window, screen});
54+
}
4855
},
4956
);
5057
return () => subscription?.remove();

‎docs/drawerlayoutandroid.md‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,12 @@ import {
9595
View,
9696
} from 'react-native';
9797
98+
type DrawerLayoutAndroidInstance = React.ComponentRef<
99+
typeof DrawerLayoutAndroid
100+
>;
101+
98102
const App = () => {
99-
const drawer = useRef<DrawerLayoutAndroid>(null);
103+
const drawer = useRef<DrawerLayoutAndroidInstance>(null);
100104
const [drawerPosition, setDrawerPosition] = useState<'left' | 'right'>(
101105
'left',
102106
);

‎docs/flexbox.md‎

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1099,12 +1099,17 @@ export default AlignSelfLayout;
10991099

11001100
```SnackPlayer name=Align%20Self&ext=tsx
11011101
import {useState} from 'react';
1102-
import {View, TouchableOpacity, Text, StyleSheet} from 'react-native';
1102+
import {
1103+
View,
1104+
TouchableOpacity,
1105+
Text,
1106+
StyleSheet,
1107+
type ViewStyle,
1108+
} from 'react-native';
11031109
import type {PropsWithChildren} from 'react';
1104-
import type {FlexAlignType} from 'react-native';
11051110
11061111
const AlignSelfLayout = () => {
1107-
const [alignSelf, setAlignSelf] = useState<FlexAlignType>('stretch');
1112+
const [alignSelf, setAlignSelf] = useState<ViewStyle['alignSelf']>('stretch');
11081113
11091114
return (
11101115
<PreviewLayout
@@ -1131,9 +1136,9 @@ const AlignSelfLayout = () => {
11311136
11321137
type PreviewLayoutProps = PropsWithChildren<{
11331138
label: string;
1134-
values: FlexAlignType[];
1135-
selectedValue: string;
1136-
setSelectedValue: (value: FlexAlignType) => void;
1139+
values: ViewStyle['alignSelf'][];
1140+
selectedValue: ViewStyle['alignSelf'];
1141+
setSelectedValue: (value: ViewStyle['alignSelf']) => void;
11371142
}>;
11381143
11391144
const PreviewLayout = ({

‎docs/improvingux.md‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,10 @@ import {
125125
StyleSheet,
126126
} from 'react-native';
127127
128+
type TextInputInstance = React.ComponentRef<typeof TextInput>;
129+
128130
const App = () => {
129-
const emailInput = useRef<TextInput>(null);
131+
const emailInput = useRef<TextInputInstance>(null);
130132
const [name, setName] = useState('');
131133
const [email, setEmail] = useState('');
132134
@@ -325,8 +327,10 @@ import {
325327
StyleSheet,
326328
} from 'react-native';
327329
330+
type TextInputInstance = React.ComponentRef<typeof TextInput>;
331+
328332
const App = () => {
329-
const emailInput = useRef<TextInput>(null);
333+
const emailInput = useRef<TextInputInstance>(null);
330334
const [email, setEmail] = useState('');
331335
332336
const submit = () => {

‎docs/layout-props.md‎

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -197,8 +197,7 @@ import {
197197
StyleSheet,
198198
Text,
199199
View,
200-
FlexAlignType,
201-
FlexStyle,
200+
ViewStyle,
202201
} from 'react-native';
203202
import {SafeAreaView, SafeAreaProvider} from 'react-native-safe-area-context';
204203
@@ -217,7 +216,7 @@ const App = () => {
217216
alignItems: alignItemsArr[alignItems],
218217
direction: directions[direction],
219218
flexWrap: wraps[wrap],
220-
} as FlexStyle;
219+
};
221220
222221
const changeSetting = (
223222
value: number,
@@ -307,29 +306,29 @@ const App = () => {
307306
);
308307
};
309308
310-
const flexDirections = [
309+
const flexDirections: ViewStyle['flexDirection'][] = [
311310
'row',
312311
'row-reverse',
313312
'column',
314313
'column-reverse',
315-
] as FlexStyle['flexDirection'][];
316-
const justifyContents = [
314+
];
315+
const justifyContents: ViewStyle['justifyContent'][] = [
317316
'flex-start',
318317
'flex-end',
319318
'center',
320319
'space-between',
321320
'space-around',
322321
'space-evenly',
323-
] as FlexStyle['justifyContent'][];
324-
const alignItemsArr = [
322+
];
323+
const alignItemsArr: ViewStyle['alignItems'][] = [
325324
'flex-start',
326325
'flex-end',
327326
'center',
328327
'stretch',
329328
'baseline',
330-
] as FlexAlignType[];
331-
const wraps = ['nowrap', 'wrap', 'wrap-reverse'];
332-
const directions = ['inherit', 'ltr', 'rtl'];
329+
];
330+
const wraps: ViewStyle['flexWrap'][] = ['nowrap', 'wrap', 'wrap-reverse'];
331+
const directions: ViewStyle['direction'][] = ['inherit', 'ltr', 'rtl'];
333332
334333
const styles = StyleSheet.create({
335334
container: {

‎docs/legacy/direct-manipulation.md‎

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -140,14 +140,16 @@ export default App;
140140
<TabItem value="typescript">
141141

142142
```SnackPlayer name=Forwarding%20setNativeProps&ext=tsx
143-
import {forwardRef} from 'react';
143+
import {forwardRef, ElementRef} from 'react';
144144
import {Text, TouchableOpacity, View} from 'react-native';
145145
146-
const MyButton = forwardRef<View, {label: string}>((props, ref) => (
147-
<View {...props} ref={ref} style={{marginTop: 50}}>
148-
<Text>{props.label}</Text>
149-
</View>
150-
));
146+
const MyButton = forwardRef<ElementRef<typeof View>, {label: string}>(
147+
(props, ref) => (
148+
<View {...props} ref={ref} style={{marginTop: 50}}>
149+
<Text>{props.label}</Text>
150+
</View>
151+
),
152+
);
151153
152154
const App = () => (
153155
<TouchableOpacity>
@@ -229,8 +231,10 @@ import {
229231
View,
230232
} from 'react-native';
231233
234+
type TextInputInstance = React.ComponentRef<typeof TextInput>;
235+
232236
const App = () => {
233-
const inputRef = useRef<TextInput>(null);
237+
const inputRef = useRef<TextInputInstance>(null);
234238
const editText = useCallback(() => {
235239
inputRef.current?.setNativeProps({text: 'Edited Text'});
236240
}, []);
@@ -379,9 +383,12 @@ type Measurements = {
379383
height: number;
380384
};
381385
386+
type TextInstance = React.ComponentRef<typeof Text>;
387+
type ViewInstance = React.ComponentRef<typeof View>;
388+
382389
const App = () => {
383-
const textContainerRef = useRef<View>(null);
384-
const textRef = useRef<Text>(null);
390+
const textContainerRef = useRef<ViewInstance>(null);
391+
const textRef = useRef<TextInstance>(null);
385392
const [measure, setMeasure] = useState<Measurements | null>(null);
386393
387394
useEffect(() => {

0 commit comments

Comments
 (0)