github necolas/react-native-web 0.22.0-rc.0

pre-release37 minutes ago

Breaking changes

Requirements and packaging

  • React 19 is required (react and react-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.js is replaced by react-native-web/asset-registry.
  • babel-plugin-react-native-web: the commonjs option is removed.

TypeScript

  • Types are now included in the package. Uninstall @types/react-native-web. Add react-native-web/types to compilerOptions.types in tsconfig.json. The types need react-native 0.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 possibly undefined. Import them from react-native-web to get their full types.

Behavior changes

  • Array style values are no longer output as fallback declarations (display: ['-webkit-flex', 'flex']). Use StyleSheet.firstThatWorks('flex', '-webkit-flex') (#2990).
  • Text now has flexShrink: 0, minWidth: 0 and minHeight: 0 by default, to match React Native (#2819, #2922).
  • TextInput: keydown events bubble. Parent onKeyDown handlers and document listeners get the keys typed in inputs (#2941).
  • onLayout no longer sends left and top. Use x and y. onLayout, measure and measureLayout no longer subtract the scroll offset of the parent from x and y (#2958).
  • aria-disabled and accessibilityState.disabled no longer set the native disabled attribute. Use the disabled prop of Pressable or the Touchable* components (#2948).
  • TextInput no longer sets autocomplete="on" by default (#2973, #2984).
  • During hydration, useColorScheme returns "light" and useWindowDimensions returns 0 sizes. They update after hydration (#2932, #2933).
  • ScrollView: refreshControl no longer wraps the scroll view. This fixes inverted lists with onRefresh that render cells upside down (#2935).

Removed components and APIs

  • CheckBox, Picker and ProgressBar. Use a community package or a web element with unstable_createElement.
  • InteractionManager, Touchable (the mixin) and YellowBox (use LogBox).
  • StyleSheet.absoluteFillObject. Use StyleSheet.absoluteFill.
  • AccessibilityInfo.fetch. Use AccessibilityInfo.isScreenReaderEnabled.
  • AccessibilityInfo.removeEventListener. Use the remove() method of the subscription.
  • Linking.removeEventListener. Use the remove() method of the subscription.

Removed props and styles

  • The accessibility* props that React Native does not have, such as accessibilityDisabled or accessibilityExpanded (#2938). Use aria-* props and role.
  • TextInput: blurOnSubmit (use submitBehavior) and autoCompleteType (use autoComplete).
  • borderStartStyle and borderEndStyle styles, which React Native does not have. Use borderInlineStartStyle and borderInlineEndStyle.

New features

  • type prop ("button", "reset" or "submit") on Pressable, Button and the Touchable* components (#2930).
  • StyleSheet.firstThatWorks for CSS fallback values (#2990).
  • PlatformColor, mapped to CSS system colors (#2936).
  • accessibilityHint, accessibilityState and accessibilityValue map to aria-* attributes (#2938). The aria-description prop is forwarded (#2957).
  • Appearance.setColorScheme (#2932). It also sets color-scheme on the root element.
  • useAnimatedValue (#2893), useAnimatedValueXY and useAnimatedColor.
  • TextInput: submitBehavior (#2931) and textAlign. autoComplete accepts the React Native values and maps them to HTML tokens.
  • Text: onTextLayout (#2987) and ellipsizeMode="clip".
  • title prop on all elements (#2803).
  • Arrays in filter (#2983), backgroundImage, backgroundPosition, backgroundRepeat, backgroundSize (#2982) and transitionProperty (#2979).
  • Image.getSize returns a promise when it is called without callbacks (#2952).
  • Image.resolveAssetSource (#2814).
  • AccessibilityInfo: isHighTextContrastEnabled and isReduceTransparencyEnabled use media queries, with their change events. setAccessibilityFocus focuses 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 onPress on Enter when role is "link" (#2926).
  • Nested Pressable: when the pointer leaves the inner one, only the Pressable that contains the pointer starts its hover again (#2920, #2947).

Text and TextInput

  • TextInput: multiline defaults to 1 row (#2861).
  • Keep onLayout and onTextLayout working when the rendered element changes, for example when href is set on Text.

ScrollView and lists

  • Animated.loop no longer blocks FlatList onEndReached (#2934).
  • VirtualizedList: don't block wheel scroll on the other axis (#2959).
  • Blur the focused input when keyboardShouldPersistTaps is "never".

Image

  • Show already loaded images on first render (#2949).
  • Support the src prop (#2852).
  • Don't apply the filter style twice (#2983).

StyleSheet

  • Don't crash on hydration when the style sheet element starts with other rules, such as an @layer block (#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" in style.pointerEvents (#2953).

Full Changelog: 0.21.4...0.22.0-rc.0

Don't miss a new react-native-web release

NewReleases is sending notifications on new releases.