Skip to content

Instantly share code, notes, and snippets.

@nerandell
Created June 2, 2020 20:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nerandell/a54281a2f1ee42cb4c1b2f6381c42eff to your computer and use it in GitHub Desktop.
Save nerandell/a54281a2f1ee42cb4c1b2f6381c42eff to your computer and use it in GitHub Desktop.
export default class App extends Component {
constructor(props) {
super(props);
this.toggleVisibility = this.toggleVisibility.bind(this);
this.state = {
isSecretVisible: false
};
}
toggleVisibility() {
this.setState({
isSecretVisible: !this.state.isSecretVisible
});
}
render() {
return (
<View testID='mainScreen' style={styles.container}>
<Button testID='secretButton'
style={styles.welcome}
onPress={this.toggleVisibility}
title={'Press to reveal secret'}/>
{this.state.isSecretVisible && (
<Image
testID='secretImage'
style={{width: 50, height: 50}}
source={{uri: 'https://facebook.github.io/react-native/docs/assets/favicon.png'}}
/>)}
</View>
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment