Skip to content

Instantly share code, notes, and snippets.

@jsorkin24
Created May 14, 2020 01:06
Show Gist options
  • Save jsorkin24/2fe177f04ab3804355c4c410607e5765 to your computer and use it in GitHub Desktop.
Save jsorkin24/2fe177f04ab3804355c4c410607e5765 to your computer and use it in GitHub Desktop.
App.js
import React, { useState, useEffect } from 'react'
import logo from './logo.svg';
import './App.css';
import LoadingScreen from './loading'
function App() {
const [loading, setLoading] = useState(true)
useEffect(() => {
setTimeout(() => setLoading(false), 6000)
}, [])
return (
<>
{loading === false ? (
<div className="App">
<header className="App-header">
<img src={logo} className="App-logo" alt="logo" />
<p>
Edit <code>src/App.js</code> and save to reload.
</p>
<a
className="App-link"
href="https://reactjs.org"
target="_blank"
rel="noopener noreferrer"
>
Learn React
</a>
</header>
</div>
) : (
<LoadingScreen />
)}
</>
);
}
export default App;
@elie222
Copy link

elie222 commented May 14, 2020

May be simpler to do loading === true ? <Loading /> : <div>...</div> (or even better: loading ? <Loading /> : <div>...</div>)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment