Android在动画.View上反应本机高度0

Android在动画.View上反应本机高度0,android,react-native,Android,React Native,我们将动画视图的高度在全高和0之间切换。当我们将视图动画设置为0高度时,它会自动重新打开,将值更改为“最小化”为1会修复视图,但它是可见的,并且不是所需的 componentWillUpdate(nextProps) { if (this.props.visible !== nextProps.visible) { const newHeight = nextProps.visible ? viewportHeight(100) : 0; Animated.timing(th

我们将
动画视图的高度在全高和0之间切换。当我们将视图动画设置为0高度时,它会自动重新打开,将值更改为“最小化”为1会修复视图,但它是可见的,并且不是所需的

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();
  }
}

事实证明,如果将
可折叠的
道具添加到视图中(这是Android特有的),将阻止优化代码从层次结构中删除视图