Skip to content

Commit 1663109

Browse files
authored
Use public react-native exports instead of deep imports (#523)
Replace every `react-native/Libraries/*` deep import with the equivalent public `react-native` export. These paths are outside RN's public API surface and are going away as the Strict API tightens. Three of the old imports were suppressed with `$FlowFixMe[missing-export]` and so resolved to `any`: `Props` (TextInput), `PressEvent` and `SyntheticEvent`. Now that they have real types, `cacheSelection` in `createStrictDOMTextInputComponent` no longer typechecks: it declared a writable `{start, end}` where RN passes a read-only `Selection`, which is invariant in Flow. Those annotations are now `Readonly<{ start: number, end: number }>`. Bumps the minimum React Native to 0.85: - `unstable_NativeView`, which replaces the `ViewNativeComponent` deep import, only exists from 0.83. - `selection` on the text input change event, which the `selectionStart`/`selectionEnd` polyfill reads, was only added to `TextInputChangeEventData` in 0.85. Both packages' `react-native` peer dependency moves from `>=0.82.0` to `>=0.85.0`, and the example apps move from Expo SDK 55 (RN 0.83.6) to SDK 56 (RN 0.85.3) so the repo typechecks against the supported floor. Nothing needed `react-native/unstable-internals-do-not-use`.
1 parent f3fbeaa commit 1663109

19 files changed

Lines changed: 940 additions & 1088 deletions

File tree

‎apps/expo-app/package.json‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@
1010
"dev:web": "expo start --web --clear"
1111
},
1212
"dependencies": {
13-
"@expo/metro-runtime": "~55.0.11",
13+
"@expo/metro-runtime": "~56.0.21",
1414
"example-ui": "0.0.55",
15-
"expo": "^55.0.0",
16-
"expo-build-properties": "~55.0.13",
17-
"expo-status-bar": "~55.0.6",
18-
"react": "19.2.0",
19-
"react-dom": "19.2.0",
20-
"react-native": "0.83.6",
15+
"expo": "^56.0.0",
16+
"expo-build-properties": "~56.0.27",
17+
"expo-status-bar": "~56.0.4",
18+
"react": "19.2.3",
19+
"react-dom": "19.2.3",
20+
"react-native": "0.85.3",
2121
"react-native-web": "^0.21.0",
2222
"react-strict-dom": "0.0.55"
2323
},

‎apps/platform-tests/package.json‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@
1010
"dev:web": "expo start --web --clear"
1111
},
1212
"dependencies": {
13-
"@expo/metro-runtime": "~55.0.11",
14-
"expo": "^55.0.0",
15-
"expo-build-properties": "~55.0.13",
16-
"expo-status-bar": "~55.0.6",
17-
"react": "19.2.0",
18-
"react-dom": "19.2.0",
19-
"react-native": "0.83.6",
13+
"@expo/metro-runtime": "~56.0.21",
14+
"expo": "^56.0.0",
15+
"expo-build-properties": "~56.0.27",
16+
"expo-status-bar": "~56.0.4",
17+
"react": "19.2.3",
18+
"react-dom": "19.2.3",
19+
"react-native": "0.85.3",
2020
"react-native-web": "^0.21.0",
2121
"react-strict-dom": "0.0.55"
2222
},

‎package-lock.json‎

Lines changed: 889 additions & 1006 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎packages/benchmarks/perf/mocks/ViewNativeComponent.js‎

Lines changed: 0 additions & 10 deletions
This file was deleted.

‎packages/benchmarks/perf/mocks/react-native.js‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,8 @@ export const TextInput = 'TextInput';
111111

112112
export const Text = 'Text';
113113

114+
export const unstable_NativeView = 'ViewNativeComponent';
115+
114116
export const unstable_TextAncestorContext = 'TextAncestorContext';
115117

116118
export const View = 'View';

‎packages/benchmarks/perf/rollup.config.mjs‎

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,6 @@ const config = [
3636
{
3737
find: /^react-native$/,
3838
replacement: path.resolve(__dirname, './mocks/react-native.js')
39-
},
40-
{
41-
find: 'react-native/Libraries/Components/View/ViewNativeComponent',
42-
replacement: path.resolve(
43-
__dirname,
44-
'./mocks/ViewNativeComponent.js'
45-
)
4639
}
4740
]
4841
}),

‎packages/react-strict-animated/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,6 @@
4444
"peerDependencies": {
4545
"react": "^19.0.0",
4646
"react-dom": "^19.0.0",
47-
"react-native": ">=0.82.0"
47+
"react-native": ">=0.85.0"
4848
}
4949
}

‎packages/react-strict-animated/src/native/Animation.js‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,10 @@ import type {
1313
SpringAnimationConfig,
1414
TimingAnimationConfig
1515
} from '../shared/SharedAnimatedTypes';
16-
import type { CompositeAnimation } from 'react-native/Libraries/Animated/Animated';
1716
import { Animated, useAnimatedValue } from 'react-native';
1817

18+
type CompositeAnimation = Animated.CompositeAnimation;
19+
1920
export function useValue(initialValue: number): Animated.Value {
2021
return useAnimatedValue(initialValue, { useNativeDriver: true });
2122
}

‎packages/react-strict-animated/src/native/components.js‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@
1010
/* eslint-disable no-unreachable */
1111

1212
import type { AnimatedStyleValue } from '../shared/SharedAnimatedTypes';
13-
import type { Text, View } from 'react-native';
14-
import type { ImageProps } from 'react-native/Libraries/Image/ImageProps';
13+
import type { ImageProps, Text, View } from 'react-native';
1514
import type { html } from 'react-strict-dom';
1615

1716
import * as React from 'react';

‎packages/react-strict-animated/src/native/index.js‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,12 @@ import type {
1414
SpringAnimationConfig,
1515
TimingAnimationConfig
1616
} from '../shared/SharedAnimatedTypes';
17-
import type { CompositeAnimation } from 'react-native/Libraries/Animated/Animated';
1817

1918
import { Animated } from 'react-native';
2019

2120
export type AnimatedValue = Animated.Value;
21+
export type CompositeAnimation = Animated.CompositeAnimation;
2222
export type {
23-
CompositeAnimation,
2423
SpringAnimationConfig,
2524
TimingAnimationConfig,
2625
InterpolationConfig

0 commit comments

Comments
 (0)