Releases: necolas/react-native-web
0.19
Best compatibility: react-native@>=0.71
React 18 support
- [change] React 18
createRoot
support. - [change] Update
Animated
to support React 18, including newAnimatedColor
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 values0
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 fortintColor
prop. - [add] Add
<TextInput>
support forenterKeyHint
prop. - [add] Add
<TextInput>
support forinputMode
prop. - [add] Add
<TextInput>
support forreadOnly
prop. - [add] Add
<TextInput>
support forrows
prop.
Deprecations
- [change] Deprecate
Touchable*
components. UsePressable
. - [change] Deprecate
Button
component. UsePressable
. - [change] Deprecate
StyleSheet.compose()
. Use style array syntax. - [change] Deprecate
accessibility*
props. Usearia-*
androle
props. - [change] Deprecate
nativeId
prop. Useid
prop. - [change] Deprecate
focusable
props. UsetabIndex
prop. - [change] Deprecate
pointerEvents
prop. UsepointerEvents
style. - [change] Deprecate
selectable
prop. UseuserSelect
style. - [change] Deprecate
fontVariant
style array values. Use space-separated string values. - [change] Deprecate
textAlignVertical
style. UseverticalAlign
style. - [change] Deprecate
transform
style array values. Use space-separated string functions. - [change] Deprecate non-standard logical styles, e.g., 'marginStart'.
- [change] Deprecate
<Image>
styleresizeMode
. UseresizeMode
prop. - [change] Deprecate
<Image>
styletintColor
. UsetintColor
prop. - [change] Deprecate
<TextInput>
propkeyboardType
. UseinputMode
prop. - [change] Deprecate
<TextInput>
propreturnKeyType
. UseenterKeyHint
prop. - [change] Deprecate
<TextInput>
propeditable
. UsereadOnly
prop. - [change] Deprecate
<TextInput>
propnumberOfLines
. Userows
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>
isposition:relative
by default. - [change] Add task queue for
InteractionManager
.
Fixes
- [fix]
Animated
now works with compiled styles. - [fix] Text inheritance of
textAlign
.
0.18
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
, andaccessibilityValue
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
orlang
prop on a component. By default, layouts are rendering RTL. To render RTL you must setdir="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
andSwitch
elements. (#2242) - Prevent href navigation for disabled Pressables and Touchables. (#2299)
Linking.openURL
supportstarget
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.
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.
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
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
andText
withaccessibilityRole="link"
. Only requires addition ofhref
prop. - Remove
unstable_createElement
element-type inference usinghref
. Fixes use with svg elements. - Remove
unstable_createElement
keyboard shim foronClick
. It no longer invokesonClick
duringonKeyDown
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 ifnumberOfLines={1}
.
0.16
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 ofwindow
dimensions and works more reliably in Safari.NativeEventEmitter
no longer inherits fromEventEmitter
and does not include theremoveSubscription
method.
New features
- Flow types are now exported. Thanks @comp615
0.15.0
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 theisRTL
anddoLeftAndRightSwapInRTL
properties. They must now be accessed using thegetConstants()
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 toText
andView
. The value is an object withrel
,target
, anddownload
properties. This replaces the undocumentedrel
andtarget
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 theaddEventListener
methods. - The deprecated
importantForAccessibility
prop has been removed. UseaccessibilityHidden
instead. - The undocumented
data-focusable
attribute has also been removed from rendered DOM nodes. - The undocumented
disabled
prop has been removed fromView
andText
; useaccessibilityDisabled
instead.
New features
- Pressable has added
onHoverIn
andonHoverOut
props. - All ARIA properties are now supported via equivalent
accessibility*
props. The undocumented support foraria-*
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. Usefocusable
instead.
Documentation
This release will include a rewrite of the documentation site and interactive examples.
https://necolas.github.io/react-native-web/
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
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.
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
This release includes many significant changes and improvements.
- 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. - 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.
- 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 nativeclick
events and will be called in almost every situation a nativeclick
event is called. TheonPress
prop ofTouchable*
components now receives aSyntheticMouseEvent
not aSyntheticResponderEvent
. It may be fired without a precedingonPressIn
. - 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. Useref
instead. ThefindNodeHandle
andfindDOMNode
APIs are discouraged and are not safe with function components or concurrent mode. - The
forwardedRef
props have been removed. Theref
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. UsedataSet
instead. For example,dataSet={{ someName: 1 }}
. - The
onLayout
prop now requires aResizeObserver
polyfill to work, and does not fallback to windowresize
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 usingaria-*
props for now.
New features
- Added
View
support foraccessibilityValue
. - Added the
Pressable
component. - Add the
Appearance
API anduseColorScheme
hook.
Fixes
- The active touch responder will now be terminated when the body scrolls, context menu appears, etc.
- Performance improvements for Touchables.
TheonPress
event can now be used topreventDefault
the native click behavior (this is no longer done automatically) - Fixes
Image
support for variable resolution images (requires bundler integration). - Fixes
TextInput
support foronContentSizeChange
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
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 tounstable_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 fromView
andText
to the host DOM element. - Remove deprecated
accessibilityTraits
andaccessibilityComponentType
props (ae94551) - Remove
resizeMode
static fromImage
(c35f849) - Remove
placeholderTextColor
fromunstable_createElement
props. Instead, this is now exposed as astyle
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
andaccessibilityState
props (d57fb6e) - Add support for native "thin" scrollbars (e0412ac)
- Add support for
forwardedRef
onText
andView
; use this instead offindNodeHandle
to get a reference to the native element. (React has deprecatedfindDOMNode
in Strict Mode, and you can anticipate the same happening tofindNodeHandle
.) - Add a
disabled
prop toTextInput
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
0.11.0
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 fromImage
(49edcb2) - Replace
outline
withoutline{Color,Style,Width}
styles (f048d84) - Replace
animationName
withanimationKeyframes
style prop.
Deprecations
- The
className
prop onView
andText
is deprecated and will be removed shortly (d50f630)
New features
- Add
TextInput
support foronContentSizeChange
, by @awinograd (67979b7) - Add
Text
support fornumberOfLines
prop value greater than1
. 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
andtextShadowColor
are provided, by @skahack (cf7b020) - Fix animation style prop types.
- Fix use of
maxWidth
withText
usingnumberOfLines
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
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 thewhich
property. (8925bf7)
New features
- Support for the new
accessibilityRole
andaccessibilityStates
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
ifnativeEvent.location{X,Y}
is accessed (40c433c by @hushicai) - Improve the performance of the style resolver for registered styles (2b77bfd by @sayrer)