LayoutAnimation主要用于View,常用来更新flexbox布局
import React, { Component } from “react”;
import { LayoutAnimation, View, Text, Button } from “react-native”;
export default class Demo3 extends Component {
constructor(props) {
super(props);
this.state = {
w: 100,
h: 100
};
}
abc = () => {
LayoutAnimation.spring();
this.setState({
w: this.state.w + 15,
h: this.state.h + 15
});
};
render() {
return (
<View
style={{
width: this.state.h,
height: this.state.w,
backgroundColor: “#ddd”
}}
>
);
}
}