2

I'm a brand new junior dev working on a react-native app for the first time. I have been searching for quite a while for a way to add a link to the text of a react-native checkbox's value text. If anyone has a link to documentation that might explain what I want to do, I would be super appreciative since I haven't found anything helpful yet. I saw that you can not add html elements into native after I tried a number of variations of anchors. I've tried adding Link to variations and attempted to add an onPress function to the label. I'm grasping at straws here... is this even possible to do?

To be clear, I want a user to be able to press the words "Terms of Service" and have it link to the page that has the terms

{this.props.isUser &&
  <CheckBox
    containerStyle={styles.checkbox}
    onChange={(event, checked) => this.updateAttr('terms', checked)}
    value={this.props.program.terms}
    label="I have read and understand the Terms of Service"
    labelLines={2}
   />
 }
emcent
  • 23
  • 4

1 Answers1

2

Instead of adding the "I accept...." as a label to checkbox, put the Check box without any label and the text 'I have read' as separate Text elements inside a view element and align them accordingly. Then inside the view, put the terms and conditions part inside a touchable and use React Native Linking to link the touchable to open a URL when touched. https://facebook.github.io/react-native/docs/linking.html React-Native Open Url in default web browser

Hisham Mubarak
  • 1,559
  • 3
  • 22
  • 28
  • Thanks, I thought this might be the solution, but I thought there may be another way to achieve this so that I didn't have to mess with the styling. I'll give it a go. I don't have enough reputation to have my upvote appear on your answer. – emcent Jan 30 '18 at 17:43
  • This is one solution I could come up with. There might be a better solution, I'm not sure. Anyways good luck. – Hisham Mubarak Jan 31 '18 at 18:39