Skip to content

Instantly share code, notes, and snippets.

@JoshK2 JoshK2/react-spinner.js
Last active Sep 2, 2019

Embed
What would you like to do?
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
You can’t perform that action at this time.