2
Animated.View
の高さを全高と0との間で切り替えます。ビューの高さを0にアニメーションすると、自動的に再開し、値を1に変更すると最小になりますが、目に見えて望ましくない。Android React Native Height 0 on Animated.View
componentWillUpdate(nextProps) {
if (this.props.visible !== nextProps.visible) {
const newHeight = nextProps.visible ? viewportHeight(100) : 0;
Animated.timing(this.state.height, {
duration: 250,
toValue: newHeight,
});
Animated.timing(this.state.searchBarHeight, {
duration: 150,
toValue: nextProps.visible ? 56 : 0,
}).start();
Animated.timing(this.state.iconBarHeight, {
duration: 150,
toValue: nextProps.visible ? 56 : 0,
}).start();
}
}