我遇到了一个错误说明(通过iOS测试):
无法读取null的属性'getScrollableNode'
在尝试使用react-native时 动画 一边 风格组件 用于反应和反应原生的造型工具。
这是一个例子 <Logo />
我创建的组件:
import React from 'react';
import { Image, Dimensions } from 'react-native';
import styled from 'styled-components/native';
const { width } = Dimensions.get('window');
const logoWidth = width - (width * 0.2);
const logoHeight = logoWidth * 0.4516;
const SLogoImage = styled(Image)`
width: ${logoWidth};
height: ${logoHeight};
`;
const Logo = ({ ...rest }) => (
<SLogoImage
source={require('../assets/logo.png')}
{...rest}
/>
);
export default Logo;
然后我将这个组件导入我的一个场景,我想在其中应用动画:
import React from 'react';
import { View, Animated } from 'react-native';
import Logo from '../components/Logo';
const ALogo = Animated.createAnimatedComponent(Logo);
class HomeScene extends Component {
state = {
fadeAnim: new Animated.Value(0)
}
componentDidMount() {
Animated.timing(
this.state.fadeAnim,
{ toValue: 1 }
).start()
}
render() {
<View>
<ALogo style={{ opacity: this.state.fadeAnim }} />
</View>
}
}
export default HomeScene;
这导致上面提到的错误,尝试谷歌搜索它,并无法找到任何形式的解释它是什么。如有必要,请随时索取更多详细信息。
相关GitHub问题: https://github.com/styled-components/styled-components/issues/341