In my react native app I'm trying to create a drawer. When I click a button it should open, and that works perfectly fine, the problem is when I close it. When I click the close button the animation blinks, kind of like opening and closing for 2-3 times before it definitely closes.
This is how I'm doing it
export default class Drawer extends Component {
constructor(props) {
super(props);
this.state = {
height: new Animated.Value(0)
}
}
showContent = () => {
Animated.spring(this.state.height, {toValue:130}).start();
}
hideContent = () => {
Animated.spring(this.state.height, {toValue:0}).start();
}
render() {
return (
<View>
<TouchableHighlight
onPress={this.showContent}
underlayColor="transparent"
>
<Text>Show</Text>
</TouchableHighlight>
<TouchableHighlight
onPress={this.hideContent}
underlayColor="transparent"
>
<Text>Hide</Text>
</TouchableHighlight>
<Animated.View style={{height: this.state.height}}>
<Text>Content</Text>
</Animated.View>
</View>
);
}
}