Skip to content

Instantly share code, notes, and snippets.

@JoshK2
Last active July 12, 2021 12:09
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JoshK2/6329fb3bc3cc3eed765ab03fc19cee52 to your computer and use it in GitHub Desktop.
Save JoshK2/6329fb3bc3cc3eed765ab03fc19cee52 to your computer and use it in GitHub Desktop.
Using loading animation/react spinner - https://github.com/JoshK2/react-spinners-css
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