importReact,{Component}from'react';import{StyleSheet,Text,View}from'react-native';conststyles=StyleSheet.create({container:{flex:1,justifyContent:'center',alignItems:'center',backgroundColor:'#F5FCFF'},header:{fontWeight:'bold',fontSize:20},text:{padding:40}});exportdefaultclassLoremIpsumScreenextendsComponent{constructor(props){super(props);this.state={text:'Loading...'};}asynccomponentDidMount(){awaitdelay(3000);letnewTextResponse=awaitfetch('https://baconipsum.com/api/?type=meat-and-filler&sentences=3&format=text&start-with-lorem=1');letnewText=awaitnewTextResponse.text();this.setState({text:newText});}render(){return(<Viewstyle={styles.container}><Textstyle={styles.header}>MOBILEVERSION</Text><Textstyle={styles.text}>{this.state.text}</Text></View>);}}// helper function to insert delays in async functionsfunctiondelay(ms){returnnewPromise(resolve=>{setTimeout(()=>{resolve();},ms);});}
Comments (0)
HTTPSSSH
You can clone a snippet to your computer for local editing.
Learn more.