我正在开发一个使用类组件的本机应用程序。类组件使我能够只用4行代码动画:
componentWillUpdate() {
UIManager.setLayoutAnimationEnabledExperimental && UIManager.setLayoutAnimationEnabledExperimental(true);
LayoutAnimation.easeInEaseOut();
}现在,不再推荐类组件使用react,而不再推荐使用功能性组件。我想知道如何在功能组件中实现与上面的代码相同的动画?
发布于 2022-03-22 10:58:42
尝尝这个,
import {LayoutAnimation, Platform, UIManager} from 'react-native';
if (Platform.OS === 'android') {
UIManager.setLayoutAnimationEnabledExperimental &&
UIManager.setLayoutAnimationEnabledExperimental(true);
}
const setAnimation = () => {
LayoutAnimation.configureNext({
duration: 250,
update: {
type: LayoutAnimation.Types.easeInEaseOut,
springDamping: 0.7,
},
});
LayoutAnimation.configureNext({
duration: 500,
create: {
type: LayoutAnimation.Types.easeInEaseOut,
property: LayoutAnimation.Properties.scaleXY,
springDamping: 0.7,
},
});
};https://stackoverflow.com/questions/71570784
复制相似问题