Skip to content

Releases: necolas/react-native-web

0.19

27 Mar 17:45
Compare
Choose a tag to compare

Best compatibility: react-native@>=0.71

React 18 support

  • [change] React 18 createRoot support.
  • [change] Update Animated to support React 18, including new AnimatedColor node.
  • [change] Update ScrollView to Class component for React 18 support.

New features

  • [add] Map 'button' and 'paragraph' role to equivalent semantic HTML elements.
  • [add] Add support for aria-* props.
  • [add] Add support for role prop.
  • [add] Add support for id prop.
  • [add] Add support for tabIndex prop (only values 0 and -1).
  • [add] Support for PointerEvent props.
  • [add] Add support for pointerEvents style.
  • [add] Add support for userSelect style.
  • [add] Add polyfilled support for W3C logical styles (e.g., insetInline.)
  • [add] Add <Image> support for tintColor prop.
  • [add] Add <TextInput> support for enterKeyHint prop.
  • [add] Add <TextInput> support for inputMode prop.
  • [add] Add <TextInput> support for readOnly prop.
  • [add] Add <TextInput> support for rows prop.

Deprecations

  • [change] Deprecate Touchable* components. Use Pressable.
  • [change] Deprecate Button component. Use Pressable.
  • [change] Deprecate StyleSheet.compose(). Use style array syntax.
  • [change] Deprecate accessibility* props. Use aria-* and role props.
  • [change] Deprecate nativeId prop. Use id prop.
  • [change] Deprecate focusable props. Use tabIndex prop.
  • [change] Deprecate pointerEvents prop. Use pointerEvents style.
  • [change] Deprecate selectable prop. Use userSelect style.
  • [change] Deprecate fontVariant style array values. Use space-separated string values.
  • [change] Deprecate textAlignVertical style. Use verticalAlign style.
  • [change] Deprecate transform style array values. Use space-separated string functions.
  • [change] Deprecate non-standard logical styles, e.g., 'marginStart'.
  • [change] Deprecate <Image> style resizeMode. Use resizeMode prop.
  • [change] Deprecate <Image> style tintColor. Use tintColor prop.
  • [change] Deprecate <TextInput> prop keyboardType. Use inputMode prop.
  • [change] Deprecate <TextInput> prop returnKeyType. Use enterKeyHint prop.
  • [change] Deprecate <TextInput> prop editable. Use readOnly prop.
  • [change] Deprecate <TextInput> prop numberOfLines. Use rows prop.
  • [change] Deprecate BackHandler API.

Breaking changes

  • [change] Remove previously deprecated Android/iOS platform-specific exports.
  • [change] Remove previously deprecated setNativeProps API.
  • [change] Remove previously deprecated AppState.removeListener API.
  • [change] <Text> is position:relative by default.
  • [change] Add task queue for InteractionManager.

Fixes

  • [fix] Animated now works with compiled styles.
  • [fix] Text inheritance of textAlign.

0.18

10 Jun 20:39
Compare
Choose a tag to compare

Breaking changes

  • Browser support has been reduced. Changes as follows: Safari 10.1+, Edge (Chromium), no IE, no legacy Android browser.
  • Styles are inserted on module eval, not component render. This is needed to account for changes to rendering in React 18.
  • Style sheets rendered on the server will now include styles from all the eval-ed modules, rather than only the styles produced by the initial render.
  • StyleSheet.create() is now the identify function, returning the input style objects. Previously, it replaced styles with numeric ids. This improves compatibility with React Native, but accessing the returned style objects at runtime is still not recommended as it can prevent static extraction to CSS. (#2068)
  • StyleSheet.getSheet() can be used on the server to retrieve the current style sheet as a CSS string. (#2196)
  • I18nManager is now a mock API included only for compatibility with React Native. The ability to flip left/right properties or values has now been removed entirely (use start/end instead). See below for new localization APIs.
  • Inline styles are no longer automatically vendor-prefixed. This improves inline style performance and discourages use of inline styles. This should have little effect in practice if your app is predominantly using StyleSheet.create().
  • The deprecated accessible, accessibilityState, and accessibilityValue props have been removed.
  • The :focus-visible polyfill has been removed, as by default modern browsers no longer show focus rings for pointer interactions.
  • VirtualizedList, FlatList, and SectionList vendor components have been updated to match latest React Native. (#2241) Thanks to @DavidRieman.
  • The legacy jest preset and snapshot serializer has been removed from the npm package.
  • The unstable_createElement API has changed. Children are no longer accepted as the 3rd argument, they must be included in the props as the 2nd argument. The 3rd argument is now an options object with a field to set the expected writing direction ({ writingDirection }).

New features

  • Localized LTR/RTL layouts can now be nesting to arbitrary depths simply by setting the dir or lang prop on a component. By default, layouts are rendering RTL. To render RTL you must set dir="rtl" on an outer element rendered by React.
  • Localized LTR/RTL layouts can be switched dynamically at runtime.
  • useLocaleContext is a new export API. Use it to query a component's locale and writing direction context for fine-grained control over localized layout.
  • Rendering into multiple windows and shadow roots in now supported. (#1517, #2138)
  • Extraction to static CSS and consumption of external CSS is now possible but not yet recommended. The StyleSheet runtime can consume any styles that match an expected format, but StyleSheet.flatten cannot work with extracted styles. (See below for more details.)

Fixes

  • Fixes static and dynamic shortform / longform deduplication. (#2007)
  • Display the focus ring on CheckBox and Switch elements. (#2242)
  • Prevent href navigation for disabled Pressables and Touchables. (#2299)
  • Linking.openURL supports target value. (#2277)

Notes

StyleSheet runtime

StyleSheet has been rewritten to better separate the runtime from the compiler. The performance of the new merging runtime is on par with using css-modules. The core runtime is a standalone package called styleQ; refer to the styleQ documentation for more details.

image

The performance of inline styles has also been significantly improved, although StyleSheet still has to perform extra work to transform non-standard React Native styles and polyfill logical styles.

image

The StyleSheet import is now a standalone module. StyleSheet itself is a function that can be called to resolve styles to DOM className and style values, e.g.,

const [ className, inlineStyle ] = StyleSheet([ styles.root, prop.styles ])

StyleSheet extraction

One of the benefits behind the new architecture is that StyleSheet can resolve compiled styles that conform to the expected format, whether they are produced by the built-in compiler or an external source. However, this is not yet recommended, as explained below.

Style compilers must produce annotated objects that are treated as class name maps, and classes are de-duplicated based on whether they share the same key, e.g.,

{
  $$css: true,
  display: 'display-class',
  opacity: 'opacity-class'
}

This is the first step towards allowing 3rd party tools to extract styles to static CSS files, and optionally dropping the client-side compiler, without needing to integrate deeply with the StyleSheet runtime or having to modify props/prop values in the source code, i.e., only the StyleSheet.create() call needs transforming by the compiler.

The existence of the StyleSheet.flatten() API is a problem for build-time compiling of some styles. Components that flatten styles (e.g., Animated, Image) expect to be able to work with the source styles, and use the source values at runtime. A compiler that aims to extract all styles and have no runtime transform would also need to disallow the use of StyleSheet.flatten() entirely. A future release of React Native for Web may remove use of StyleSheet.flatten from internal implementations, but cannot prevent this API from being used in product code or 3rd party packages.

0.17.0

17 Jun 16:54
Compare
Choose a tag to compare

Accessibility improvements and breaking changes to unstable APIs.

Breaking changes

  • Remove special treatment of elements with accessibilityRole="menuitem". It no longer adds elements to the tab flow.
  • Remove anchor element inference from View and Text with accessibilityRole="link". Only requires addition of href prop.
  • Remove unstable_createElement element-type inference using href. Fixes use with svg elements.
  • Remove unstable_createElement keyboard shim for onClick. It no longer invokes onClick during onKeyDown for keyboard interactions on elements that are not natively interactive.

Fixes

  • Fix Pressable support for keyboard interactions if element is unmounted during interaction.
  • Remove unnecessary CSS reset for input number spin buttons.
  • Fix ProgressBar & Switch rendering in Windows High Contrast mode
  • Text preserves white-space if numberOfLines={1}.

0.16

20 Apr 19:22
Compare
Choose a tag to compare

This release includes Flow type exports, updates vendored modules, and miscellaneous bug fixes.

Breaking changes

  • Animated & VirtualizedList have been updated from React Native.
  • Dimensions has changed the source of window dimensions and works more reliably in Safari.
  • NativeEventEmitter no longer inherits from EventEmitter and does not include the removeSubscription method.

New features

  • Flow types are now exported. Thanks @comp615

0.15.0

12 Feb 19:03
Compare
Choose a tag to compare

This release introduces improved accessibility features and new documentation. It includes relatively minor breaking changes.

Breaking changes

  • React 17 is a peer dependency.
  • The I18nManager API has removed the isRTL and doLeftAndRightSwapInRTL properties. They must now be accessed using the getConstants() method, which returns an object with the same properties. This was an undocumented breaking change in a previous version of React Native.
  • The focusable prop now determines whether an element appears in the keyboard tab flow.
  • The hrefAttrs prop has been added to Text and View. The value is an object with rel, target, and download properties. This replaces the undocumented rel and target props.
  • The automatic addition of rel="noopener" to anchors has been removed.
  • The Linking.openURL(url) API now opens the url in new tab.
  • The Linking API now includes the addEventListener methods.
  • The deprecated importantForAccessibility prop has been removed. Use accessibilityHidden instead.
  • The undocumented data-focusable attribute has also been removed from rendered DOM nodes.
  • The undocumented disabled prop has been removed from View and Text; use accessibilityDisabled instead.

New features

  • Pressable has added onHoverIn and onHoverOut props.
  • All ARIA properties are now supported via equivalent accessibility* props. The undocumented support for aria-* prop forwarding remains and will be removed in a future version.
  • Additional accessibilityRole values are mapped to HTML element equivalents.
  • CSS aspectRatio property is now available in browsers with support.

Deprecations

  • The accessible prop is deprecated and will be removed in the next minor release. React Native for Web will follow React Native for Windows/macOS in removing this prop. Use focusable instead.

Documentation

This release will include a rewrite of the documentation site and interactive examples.

https://necolas.github.io/react-native-web/

image

The examples will be embedded in relevant pages via a Next.js-powered codesandbox, making it easy for people to fork the example app from their browsers.

0.14.0

09 Oct 20:00
Compare
Choose a tag to compare

This is a relatively small release that introduces a couple of new features and makes a change to the default flexBasis value of View. There are no breaking API changes and it should be straight-forward to upgrade from 0.13. Thank you to Twitter Engineering and everyone else who tested and helped to improve the 0.14 release.

Breaking changes

Default flex-basis value of Views

React Native has an implementation of flexbox that does not quite follow the W3C spec for flexbox. Previously, React Native for Web attempted to replicate the React Native rendering by setting flexBasis to 0%. However, this created its own problems where views could collapse down to 0px in height on the web. This patch sets the default flexBasis back to auto. This will occasionally cause different rendering inconsistencies with React Native, which can be addressed by making changes small to existing React Native styles to set the flexBasis back to 0% or the desired percentage. And ultimately, Yoga 2 intends to correct its flexbox implementation and this will make its way into React Native eventually.

Fix #1640, #1604, #1264

New features

Modal implementation

A Modal implementation using CSS animations and ARIA, courtesy of @imnotjames. When the modal is open the rest of the app is hidden from screen readers via aria-modal. Focus is contained within the modal. When the Escape key is pressed, the onRequestClose function is called on the top-most modal.

Fix #1020

Pressable support for hover state

The Pressable component state now includes hover, which scoped is scoped to a Pressable instance and does not bubble to ancestor Pressables. This behavior aligns with the behavior of the focus and press states.

<Pressable
  children={
    ({ pressed, hovered, focused }) => {}
  }
  style={
    ({ pressed, hovered, focused }) => {}
  }
/>

Fix #1708

0.13

26 Jun 22:17
Compare
Choose a tag to compare

This release includes many significant changes and improvements.

  1. Modern React: implements components using function components and hooks. It removes use of various legacy React features such as legacy context and create-react-class. These changes mean better support for Concurrent Mode, Fast Refresh, and interaction handling.
  2. Gesture Responder System: this has be rewritten from scratch in user space. Dozens of bugs have been fixed and the system is heavily unit tested; it's now the most accurate and well integrated implementation of any platform.
  3. React Alternatives: this release removes the use of unstable React DOM APIs. React Native for Web can now be used with Preact and other libraries that are API compatible with React. However, it should be noted that benchmark rendering of 0.13 with React DOM is a lot faster than Preact.

Breaking changes

  • The Responder System has been rewritten. This should not be a breaking change (and comes with many bug fixes), but since the system is implemented in user-space rather than React, it may encounter differences in timings relative to the ReactDOM events.
  • The onPress callback on Touchables is now backed by native click events and will be called in almost every situation a native click event is called. The onPress prop of Touchable* components now receives a SyntheticMouseEvent not a SyntheticResponderEvent. It may be fired without a preceding onPressIn.
  • All the components are implemented as function components, so using findNodeHandle to get a reference to the component's underlying host node will not work. Use ref instead. The findNodeHandle and findDOMNode APIs are discouraged and are not safe with function components or concurrent mode.
  • The forwardedRef props have been removed. The ref on a component will now return a ref to the host node, which has the imperative methods attached to it.
  • The hitSlop prop has been removed. This caused incorrect hit targets for mouse interactions. The browser's built-in touch hitslop will be relied on instead.
  • The prop types of each component are now explicit. Unknown props will not be forwarded to the underlying React DOM component.
  • Forwarding of data-* props is no longer supported. Use dataSet instead. For example, dataSet={{ someName: 1 }}.
  • The onLayout prop now requires a ResizeObserver polyfill to work, and does not fallback to window resize events.
  • Removed React Native APIs that have been removed or deprecated: TabBarIOS, TimePickerAndroid
  • Removed support for HTML microdata props. Microdata has been removed from the HTML spec.
  • Removed the accessibilityRelationship prop. This prop was not added to React Native. Continue using aria-* props for now.

New features

  • Added View support for accessibilityValue.
  • Added the Pressable component.
  • Add the Appearance API and useColorScheme hook.

Fixes

  • The active touch responder will now be terminated when the body scrolls, context menu appears, etc.
  • Performance improvements for Touchables.
    The onPress event can now be used to preventDefault the native click behavior (this is no longer done automatically)
  • Fixes Image support for variable resolution images (requires bundler integration).
  • Fixes TextInput support for onContentSizeChange to allow auto-grow textareas.
  • Fixes the correctness of setting styles using ref.setNativeProps. Recommend avoiding this API as it is expected to be deprecated in React Native.

0.12.0

28 Jan 18:19
Compare
Choose a tag to compare

This release includes compatibility with the vast majority of React Native v0.60. React features like createContext and forwardRef have been integrated, as well as several breaking changes from upstream. In most cases, you should be able to update smoothly if not using components and APIs deprecated in React Native.

Breaking changes

  • createElement is renamed to unstable_createElement and is an unstable implementation detail for now (d4b9f35)
  • Remove prop types exports from package. These are deprecated in React Native and introduce significant DEV time performance cost. Flow types are now preferred (1ad1693)
  • Remove the following exports which are all deprecated or removed in React Native core: AsyncStorage, AlertIOS, ActionSheetIOS, CameraRoll, DatePickerAndroid, DatePickerIOS, ImageEditor, ImagePickerIOS, ImageStore, ListView, MaskedViewIOS, NavigatorIOS, NetInfo, PickerIOS, ProgressBarAndroid, ProgressViewIOS, PushNotificationsIOS, SegmentedControlIOS, Slider, SnapshotViewIOS, StatusBarIOS, SwipeableListView, ToolbarAndroid, VibrationIOS, ViewPagerAndroid, WebView.
  • Hydrating SSR markup is now an explicit opt-in via options passed to AppRegistry.runApplication (afb8d3b)
  • Remove deprecated accessibilityStates prop (d57fb6e)
  • Remove deprecated className prop and forwarding of arbitrary props from View and Text to the host DOM element.
  • Remove deprecated accessibilityTraits and accessibilityComponentType props (ae94551)
  • Remove resizeMode static from Image (c35f849)
  • Remove placeholderTextColor from unstable_createElement props. Instead, this is now exposed as a style property (287251a)
  • Update Switch prop types to latest from React Native (aa8593b)

New features

  • The following exports have been updated to align with React Native: Animated, Touchable, TouchableHighlight, TouchableOpacity, TouchableWithoutFeedback, FlatList, SectionList, VirtualizedList, VirtualizedSectionList.
  • Add support for accessibilityRelationship and accessibilityState props (d57fb6e)
  • Add support for native "thin" scrollbars (e0412ac)
  • Add support for forwardedRef on Text and View; use this instead of findNodeHandle to get a reference to the native element. (React has deprecated findDOMNode in Strict Mode, and you can anticipate the same happening to findNodeHandle.)
  • Add a disabled prop to TextInput to support disabling the element (fc033a3)
  • Add useWindowDimensions hook (df1b62c)
  • Add support for Platform.isTesting (ad674e4)
  • Only inject the ResponderEventPlugin when client rendering (250ee3c)

Fixes

  • Fix support for disabling scroll in ScrollView for touch interactions (e22f0be)
  • Fix support for autoComplete on TextInput (b10711b)
  • Remove UA default margin from TextInput (5334a4f)

0.11.0

13 Mar 01:15
Compare
Choose a tag to compare

This release includes: a refactor of StyleSheet internals to improve browser layout times; improved compatibility with React Native; reduced bundle sizes in worse-case-scenario; and improved text truncation capabilities in supporting browsers.

Breaking changes

  • CSS output has changed to better optimize browser layout times (9f860b8 and d4417e9)
  • Remove export default from the ESM entry point, to help with tree-shaking (69bd0f6)
  • Remove ART from the exports to reduce CJS bundle size (3d3ea9a)
  • Remove resizeMode static from Image (49edcb2)
  • Replace outline with outline{Color,Style,Width} styles (f048d84)
  • Replace animationName with animationKeyframes style prop.

Deprecations

  • The className prop on View and Text is deprecated and will be removed shortly (d50f630)

New features

  • Add TextInput support for onContentSizeChange, by @awinograd (67979b7)
  • Add Text support for numberOfLines prop value greater than 1. Only supported in WebKit and Blink browsers; limited localization support (f048d84)

Fixes

  • Organize unimplemented modules in directories to help reduce CJS build size, by @EvanBacon (2a418be)
  • Fix the NativeEventEmitter implementation, by @EvanBacon (9ce2b5b)
  • Allow text shadow to be set if only a textShadowBlur and textShadowColor are provided, by @skahack (cf7b020)
  • Fix animation style prop types.
  • Fix use of maxWidth with Text using numberOfLines prop.
  • Passing null values for style props now produces improved compatibility with React Native rendering.

Appendix

  • StyleSheet refactor reduces browser layout times up to 30% in the stress tests.
  • StyleSheet refactor reduces HTML payload size for SRR, e.g., the size of the HTML produced by the Twitter PWA's home timeline screen is reduced from 25.56 KB to 21.35 KB (-16%) gzipped.

0.10.0

30 Jan 22:37
Compare
Choose a tag to compare

This release includes accessibility, measurement, performance and reliability improvements.

Breaking changes

  • The measurements provided by onLayout have been fixed but if you are depending on bugs in the prior implementation you may experience breaking changes. The dimension values will now include border size; the position values will now include transforms. (93eb3f0)
  • TextInput events no longer include the which property. (8925bf7)

New features

  • Support for the new accessibilityRole and accessibilityStates props (4040151)

Fixes

The following fixes were included in 0.9.x patch releases, and I want to bring attention to them in these release notes. Thank you to the people who contributed these improvements.

  • Fix a memory leak in the applyLayout registry (ad188a7 by @comp615)
  • Only observe resizes for elements making use of the 'onLayout' prop which improves ResizeObserver polyfill performance (d31bdf2 by @comp615)
  • Cache the Clipboard.isAvailable() value to avoid forced style calculation in Chrome (5855e55 by @comp615)
  • Improve the performance of the modality style helper (4b9a5fd and 1b7ce4e by @giuseppeg)
  • Only call node.getBoundingClientRect if nativeEvent.location{X,Y} is accessed (40c433c by @hushicai)
  • Improve the performance of the style resolver for registered styles (2b77bfd by @sayrer)