0

我正在尝试使用按钮运行课程,但无法使其正常工作。我知道,如果我想运行一个类,我只需要使用:

 <className /> 

所以,我试着这样做:

    <Button
    title="Right button"
    onPress={() => <className />}
  />

但是,我遇到了一个错误,所以我可能做错了什么。任何人都可以帮忙吗?

4

1 回答 1

0

“上课”并没有真正的意义,所以我要刺穿你的意思。可能您想在单击按钮时呈现类组件。在这种情况下使用类似的东西:

  <Button
    title="Right button"
    onPress={() => this.setState({showMyComponent: true})}
  />
  { this.state.showMyComponent && <className /> }

请注意,这并不完整——您可能还希望能够隐藏它等等,但这是一个开始。

于 2020-02-16T22:59:33.277 回答