Answers for "react native create view dynamically"

1

react native create view dynamically

//you define a function to generate the view
viewGenerator(isTrue){
  if(isTrue){
    return( //you return the view you want to generate
      <View>
      	<Text>Generated text</Text>
      </View>
    );
  }
}

render(){
  return(
    <View>
      //then you use it inside your view like this
      {this.viewGenerator(true)}
    </View>
  );
}
Posted by: Guest on May-24-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language