Skip to content

Instantly share code, notes, and snippets.

@jacobp100
Created February 28, 2017 15:30
Show Gist options
  • Save jacobp100/b113f91054e8b349095b52c8bd8ffe07 to your computer and use it in GitHub Desktop.
Save jacobp100/b113f91054e8b349095b52c8bd8ffe07 to your computer and use it in GitHub Desktop.
class TouchableCustom extends Component {
constructor() {
super();
this.state = { active: false };
this.onPressIn = () => this.setState({ active: true });
this.onPressOut = () => this.setState({ active: false });
}
render() {
const { active } = this.state;
const { children } = this.props;
return (
<TouchableWithoutFeedback
onPressIn={this.onPressIn}
onPressOut={this.onPressOut}
>
{children(active)}
</TouchableWithoutFeedback>
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment