Skip to content

Instantly share code, notes, and snippets.

@nerandell
Last active March 5, 2019 17:58
Show Gist options
  • Save nerandell/52d5ee03eb2da72cae25d24a56b27a1c to your computer and use it in GitHub Desktop.
Save nerandell/52d5ee03eb2da72cae25d24a56b27a1c to your computer and use it in GitHub Desktop.
Sample component for detox testing
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