Last active
July 12, 2021 12:09
-
-
Save JoshK2/6329fb3bc3cc3eed765ab03fc19cee52 to your computer and use it in GitHub Desktop.
Using loading animation/react spinner - https://github.com/JoshK2/react-spinners-css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { Component } from 'react'; | |
import Facebook from '@bit/joshk.react-spinners-css.facebook'; | |
class App extends Component { | |
state = { | |
data: [] | |
} | |
componentDidMount(){ | |
setTimeout(() => { this.setState({ data: ['Mercedes', 'Jaguar', 'Volvo', 'BMW'] }) }, 5000); | |
} | |
render(){ | |
const data = this.state.data; | |
if(data.length > 0) { | |
return( | |
<div> | |
<h1>Cars:</h1> | |
{ | |
data.map((value, index) => { | |
return <div key={index}>{value}</div> | |
}) | |
} | |
</div> | |
) | |
} else { | |
return( | |
<div> | |
<Facebook /> | |
</div> | |
) | |
} | |
} | |
} | |
export default App; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment