Breaking changes
Requirements and packaging
- React 19 is required (
reactandreact-dom). - The package is ESM only. Jest must transform it: add
"transformIgnorePatterns": ["/node_modules/(?!react-native-web/)"]to the Jest config. - Supported browsers are now Chrome / Edge 96+, Firefox 94+ and Safari / iOS Safari 15.1+. Vendor prefixing adds
-webkit-only, for the properties that still need it. Expect Jest snapshot changes. - Flow types are no longer shipped (#2974).
react-native-web/asset-registry.jsis replaced byreact-native-web/asset-registry.babel-plugin-react-native-web: thecommonjsoption is removed.
TypeScript
- Types are now included in the package. Uninstall
@types/react-native-web. Addreact-native-web/typestocompilerOptions.typesintsconfig.json. The types needreact-native0.88 or later. In a web-only app, install it as a dev dependency. - On
react-native, web-only APIs (unstable_createElement,useLocaleContext,StyleSheet.firstThatWorks, …) are typed as possiblyundefined. Import them fromreact-native-webto get their full types.
Behavior changes
- Array style values are no longer output as fallback declarations (
display: ['-webkit-flex', 'flex']). UseStyleSheet.firstThatWorks('flex', '-webkit-flex')(#2990). Textnow hasflexShrink: 0,minWidth: 0andminHeight: 0by default, to match React Native (#2819, #2922).TextInput: keydown events bubble. ParentonKeyDownhandlers and document listeners get the keys typed in inputs (#2941).onLayoutno longer sendsleftandtop. Usexandy.onLayout,measureandmeasureLayoutno longer subtract the scroll offset of the parent fromxandy(#2958).aria-disabledandaccessibilityState.disabledno longer set the nativedisabledattribute. Use thedisabledprop ofPressableor theTouchable*components (#2948).TextInputno longer setsautocomplete="on"by default (#2973, #2984).- During hydration,
useColorSchemereturns"light"anduseWindowDimensionsreturns0sizes. They update after hydration (#2932, #2933). ScrollView:refreshControlno longer wraps the scroll view. This fixes inverted lists withonRefreshthat render cells upside down (#2935).
Removed components and APIs
CheckBox,PickerandProgressBar. Use a community package or a web element withunstable_createElement.InteractionManager,Touchable(the mixin) andYellowBox(useLogBox).StyleSheet.absoluteFillObject. UseStyleSheet.absoluteFill.AccessibilityInfo.fetch. UseAccessibilityInfo.isScreenReaderEnabled.AccessibilityInfo.removeEventListener. Use theremove()method of the subscription.Linking.removeEventListener. Use theremove()method of the subscription.
Removed props and styles
- The
accessibility*props that React Native does not have, such asaccessibilityDisabledoraccessibilityExpanded(#2938). Usearia-*props androle. TextInput:blurOnSubmit(usesubmitBehavior) andautoCompleteType(useautoComplete).borderStartStyleandborderEndStylestyles, which React Native does not have. UseborderInlineStartStyleandborderInlineEndStyle.
New features
typeprop ("button","reset"or"submit") onPressable,Buttonand theTouchable*components (#2930).StyleSheet.firstThatWorksfor CSS fallback values (#2990).PlatformColor, mapped to CSS system colors (#2936).accessibilityHint,accessibilityStateandaccessibilityValuemap toaria-*attributes (#2938). Thearia-descriptionprop is forwarded (#2957).Appearance.setColorScheme(#2932). It also setscolor-schemeon the root element.useAnimatedValue(#2893),useAnimatedValueXYanduseAnimatedColor.TextInput:submitBehavior(#2931) andtextAlign.autoCompleteaccepts the React Native values and maps them to HTML tokens.Text:onTextLayout(#2987) andellipsizeMode="clip".titleprop on all elements (#2803).- Arrays in
filter(#2983),backgroundImage,backgroundPosition,backgroundRepeat,backgroundSize(#2982) andtransitionProperty(#2979). Image.getSizereturns a promise when it is called without callbacks (#2952).Image.resolveAssetSource(#2814).AccessibilityInfo:isHighTextContrastEnabledandisReduceTransparencyEnableduse media queries, with their change events.setAccessibilityFocusfocuses the node. (#2923).
Fixes
Modal
- Trap focus and handle Escape as soon as the modal shows, not when its animation ends (#2879, #2962).
- Close only the top-most modal on Escape.
- Return focus to the trigger when the modal content takes focus on mount (#2986).
- Don't scroll to the first focusable element on open.
- Other focus trapping fixes (#2864, #2908, #2960).
Pressable
- Call
onPresson Enter whenroleis"link"(#2926). - Nested
Pressable: when the pointer leaves the inner one, only thePressablethat contains the pointer starts its hover again (#2920, #2947).
Text and TextInput
TextInput:multilinedefaults to 1 row (#2861).- Keep
onLayoutandonTextLayoutworking when the rendered element changes, for example whenhrefis set onText.
ScrollView and lists
Animated.loopno longer blocksFlatListonEndReached(#2934).VirtualizedList: don't block wheel scroll on the other axis (#2959).- Blur the focused input when
keyboardShouldPersistTapsis"never".
Image
- Show already loaded images on first render (#2949).
- Support the
srcprop (#2852). - Don't apply the
filterstyle twice (#2983).
StyleSheet
- Don't crash on hydration when the style sheet element starts with other rules, such as an
@layerblock (#2943). - Compiled style objects (
$$css: true, such as StyleX output) keep all their keys and are localized for RTL (#2944). - Support
"box-none"and"box-only"instyle.pointerEvents(#2953).
Full Changelog: 0.21.4...0.22.0-rc.0