我正在尝试ams
使用react-native-reanimated
. 我很确定这是因为动画组件,但无法弄清楚如何解决它。
应用程序.js
import React, {useEffect, useRef} from 'react';
import {Button, StyleSheet, Text, View} from 'react-native';
import Logo from './screens/Logo';
import Animated, { useCode, cond, eq, set } from 'react-native-reanimated';
import { withTimingTransition } from 'react-native-redash';
export default function App() {
const scale = useRef(new Animated.Value(0));
const scaleAnimation = withTimingTransition(scale.current);
useCode(() => cond(eq(scale.current, 0), set(scale.current, 1)), []);
return (
<>
<View style={styles.container}>
<View style={{ ...styles.logoContainer}}>
<Logo scale={scaleAnimation} />
</View>
</View>
<NavigationContainer>...</NavigationContainer>
</>
);
}
Logo.js
import React, {Component} from 'react';
import Animated from 'react-native-reanimated';
import {Button, StyleSheet, Text, View} from 'react-native';
const Logo = (scale) => (
<Animated.View style={{ ...styles.logo, transform: [{scale: scale}] }}>
<Text style={{ fontWeight: "400", fontSize: 36}}> ams </Text>
</Animated.View>
);
export default Logo;