import React, { useState, useEffect } from 'react'
import
{
StyleSheet, Text, View, Button,
ActivityIndicator // 活动指示器 loading
} from 'react-native'
const App = () =>
{
const [animation, setAnimation] = useState(true)
useEffect(() =>
{
closeActivityIndicator()
return () =>
{
}
}, [])
let closeActivityIndicator = () =>
{
setAnimation(!animation)
}
return (
<View style={styles.container}>
<Text style={styles.text}>羽神天下第一</Text>
{/* 活动指示器 切换 animation 属性进行显示隐藏切换 */}
<ActivityIndicator style={styles.activityIndicator} color="pink" size="large" animating={animation} />
<Button onPress={closeActivityIndicator} title='切换显示loading'></Button>
</View>
)
}
export default App
const styles = StyleSheet.create({
container: {
flex: 1,
marginTop: 70
},
text: {
color: 'pink',
textAlign: 'center',
fontSize: 24
},
activityIndicator: {
height: 80
}
})