我想在'Text'组件'onPress'中获取文本并将其设置为我的组件的状态变量.这是我的代码 -
var MyComponent = React.createClass({ getInitialState: function(){ return { myStateVariable: 'New York' } }, render: function(){ return ({ this.setState({ myStateVariable: 'London' // This works fine myStateVariable: this.children // This is not working }); } }> London {this.state.myStateVariable} ); } });
如何动态获取"文本"组件中的文本?