Created
February 28, 2017 15:30
-
-
Save jacobp100/b113f91054e8b349095b52c8bd8ffe07 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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