I want to create a new Text Component through a function called by pressing a button.
import React, { Component } from 'react';import { StyleSheet, Text, View, Button } from 'react-native';export default class App extends React.Component { constructor() { super(); this.clicks = 0; } addText() { return ( // something to add a new Text component to the View ) } ButtonPress() { this.clicks++; if (this.clicks > 0 && this.clicks % 20 == 0) { this.addText(); } } render() { return (<View style={styles.container}><Button title="Click me" onPress={this.ButtonPress.bind(this)} /></View> ); }}
I know it's possible by making an arrow function in the onPress
from the button, but I want to do it exclusively from a function.Is it possible? If so, how?Any help is appreciated.Thanks!