次のようなエラーが発生しています (iOS でテスト済み):
null のプロパティ 'getScrollableNode' を読み取ることができません
react-native のAnimated along styled-componentsスタイリング ツールを、react および 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;
次に、このコンポーネントを、アニメーションを適用したいシーンの 1 つにインポートします。
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