React-native-web: href does not work on TouchableWithoutFeedback with accessibilityRole=link

Created on 5 Dec 2020  路  2Comments  路  Source: necolas/react-native-web

The problem

I want to add a href a TouchableWithoutFeedback (this is used in the ui library I use react-native-paper) and I want the ctrl+click experience with urls on the web.
Schermafbeelding 2020-12-05 om 19 29 25

However the href does not get added to the dom, but it does with TouchableHighlight

How to reproduce
https://codesandbox.io/s/floral-fire-n7zlu?file=/src/App.js

Expected behavior
Href get's also applied with TouchableWithoutFeedback
Environment (include versions)

  • React Native for Web (version): * (latest)
  • React (version): 16.13.1
  • Browser: Chrome

Most helpful comment

Those props should be set on the element that touchable without feedback is wrapping.

See the notes in the docs: https://reactnative.dev/docs/touchablewithoutfeedback

Importantly, TouchableWithoutFeedback works by cloning its child and applying responder props to it. It is therefore required that any intermediary components pass through those props to the underlying React Native component.

So that component simply forwards props to the element it wraps, mostly responder props and some accessibility props. Nothing else. It will eventually be deprecated in favor of Pressable.

All 2 comments

Those props should be set on the element that touchable without feedback is wrapping.

See the notes in the docs: https://reactnative.dev/docs/touchablewithoutfeedback

Importantly, TouchableWithoutFeedback works by cloning its child and applying responder props to it. It is therefore required that any intermediary components pass through those props to the underlying React Native component.

So that component simply forwards props to the element it wraps, mostly responder props and some accessibility props. Nothing else. It will eventually be deprecated in favor of Pressable.

Ok thanks for the info! I have a PR open for the library to use Pressable https://github.com/callstack/react-native-paper/pull/2281. So will continue the discussion with the maintainers of react-native-paper.

Was this page helpful?
0 / 5 - 0 ratings