0

I am trying to run a class using a button but I can't make it work. I know that if I want to run a class I just need to use:

 <className /> 

So, I tried to do this:

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

However, I got an error so I'm probably doing something wrong. Can anyone help?

Damo
  • 1
  • 2

1 Answers1

0

"Running a class" doesn't really mean anything, so I'm going to have a stab at what you mean. Probably you want to render a class component when you click a button. In that case use something like:

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

Note this isn't complete - you probably want to also be able to hide it and so on, but it's a start.

see sharper
  • 11,505
  • 8
  • 46
  • 65