question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Using Touchable* inside an inline renderer, such as `a`

See original GitHub issue

Is this a bug report or a feature request?

Question (maybe feature request?)

Have you read the guidelines regarding bug report?

Yes

Have you read the documentation in its entirety?

yes

Have you made sure that your issue hasn’t already been reported/solved?

Yes

Environment

Environment: React: 16.5.0 React native: 0.57 react-native-render-html: 4.1.2

Explanation

On RN 0.55, I was able to create a renderer for a that returned a component that uses TouchableOpacity. My use case is creating rich mention tags; I look for links containing a particular attribute, and return a <Mention /> component if it matches:

a: (htmlAttribs, children, convertedCSSStyles, passProps) => {
	if (htmlAttribs["data-mentionid"]) {
		return <Mention userid={parseInt(htmlAttribs["data-mentionid"])} name={passProps.rawChildren[0].data} key={passProps.key} />;
	}

	return a(htmlAttribs, children, convertedCSSStyles, passProps);
}

However, since upgrading to RN 0.57, this no longer works because TouchableOpacity returns a View, and I therefore get a “View in Text” error because the link is inside a paragraph.

Does react-native-render-html provide any way to work around this kind of situation? I’m not really sure what the solution would be - I guess somehow ensuring the previous <Text> is ended before my custom component and a new one opened after.

I know <Text> provides an onPress prop, but styling a <Text> isn’t really flexible enough for my needs here unfortunately.

Thanks for any advice and/or considering this as a request!

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:3
  • Comments:7

github_iconTop GitHub Comments

1reaction
jsamrcommented, Jun 11, 2021

Since the foundry release (v6), every custom renderer can use onPress prop! See this example.

0reactions
jsamrcommented, Jul 4, 2020

I am closing because this issue seems to have been resolved.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Using Touchable* inside an inline renderer, such as a #262
Since the foundry release (v6), every custom renderer can use onPress prop! See this example. 1
Read more >
How to include TouchableOpacity within Text ReactNative
I tried adding it in a view then it works fine and I am able to add TouchableOpacity but from UI perspective, they...
Read more >
React Native touchable vs. pressable components
Learn the difference between touchable and pressable components in React Native, and how to implement different effects with each kind.
Read more >
touch-action - CSS: Cascading Style Sheets - MDN Web Docs
The touch-action CSS property sets how an element's region can be manipulated by a touchscreen user (for example, by zooming features built ...
Read more >
How to Show and Hide Elements in React - Telerik
In this short example below we will set the display property to be either block or none depending on the value contained within...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found