How to put button just after text in react-native like on image below?
Asked
Active
Viewed 728 times
3 Answers
1
You can use onPress
prop in Text
component. And use nested Text
You can try here: https://snack.expo.io/@vasylnahuliak/9a76b0
import React, { useState } from 'react';
import { Text, View, StyleSheet } from 'react-native';
const App = () => {
const handleLinkPress = () => {
alert('link pressed')
}
return (
<View style={styles.container}>
<Text>
Short descriptopm for trainer: Lorem ipsum dolor sit amet, consectetur
adipiscing elit, sed do eiusmod tempor incididunt ut labore.
<Text style={styles.link} onPress={handleLinkPress}> edit </Text>
</Text>
</View>
);
};
const styles = StyleSheet.create({
link: {
color: 'blue',
fontWeight: 'bold',
},
});
export default App;

Vasyl Nahuliak
- 1,912
- 2
- 14
- 32
0
You can use <TouchableOpacity></TouchableOpacity>
for example. You just have to wrap your <Text>-Tag
in it.
<TouchableOpacity> <Text> edit </Text> </TouchableOpacity>
TouchableOpacity has OnPress Events similar to a Button.

yesIamFaded
- 1,970
- 2
- 20
- 45
-
Can you write example on snack.expo.io? I guess this choice not working, because `TouchableOpacity` will be under text in this case. – Vasyl Nahuliak Jun 23 '21 at 09:04
-2
You can try with https://www.npmjs.com/package/react-native-render-html#making-your-custom-component-block-or-inline
Make edit button as an href link and you can get its onPress on onLinkPress prop

Chandan Makhija
- 1
- 1