Search code examples
javascriptcssreact-nativereact-native-stylesheet

React Native TouchableOpacity not working after setting styles of text


Hi I am new with React Native I've made a form and at the bottom of form I've added these lines New here? Create an account which on clicking "Create an account" text it should navigate on the directed screen.. but as soon as I'have added the styles to it, its not working. Here's my code:

<Text style={{left:70,top:40,color:'#898989'}}>New here?</Text>
 <TouchableOpacity onPress={()=>this.props.navigation.navigate('SignUp')}>
    <Text style={{marginLeft:145,top:17,fontSize:15,color:'#FB7956'}}>Create an account</Text>
  </TouchableOpacity>

Solution

  • add marginLeft and top property in TouchableOpacity style and remove from text style.

    <TouchableOpacity 
    onPress={()=>this.props.navigation.navigate('SignUp')} 
    style={{marginLeft:145,top:17}}>
        <Text style={{fontSize:15, color:'#FB7956'}}>Create an account</Text>
    </TouchableOpacity>