动画:文本字符串必须在<Text>组件内呈现

时间:2019-06-15 16:58:04

标签: reactjs react-native react-animated

不知道为什么我会收到此错误,有人可以帮忙吗?没有文字被渲染

render() {

const { width, height } = Dimensions.get('window')
        const animatedHeight = {
                        transform : this.animated.getTranslateTransform()
        }
        return (
            <Animated.View style={{flex:1, backgroundColor:'red'}}>
                <Animated.View style={[animatedHeight, { position: 'absolute', left: 0, right: 0, zIndex: 10, backgroundColor: 'white', height: height }]}>

                </Animated.View>
            </Animated.View>

        )
    }

1 个答案:

答案 0 :(得分:0)

我猜这是由Animated.View子项中隐藏的空格引起的。自封闭标签可以解决此问题。

<Animated.View
  style={[
    animatedHeight, 
    {
      position: 'absolute',
      left: 0, 
      right: 0, 
      zIndex: 10, 
      backgroundColor: 'white', 
      height: height
    }
  ]}
/>