Created
April 25, 2020 18:38
-
-
Save mohnatus/e60581b40fef176b605c91fc7ce1524d to your computer and use it in GitHub Desktop.
Skeleton screens (React)
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, { useState, useEffect } from "react"; | |
import "./App.css"; | |
import dummyData from "./data"; | |
import CardList from "./components/CardList"; | |
const App = () => { | |
const [videos, setVideos] = useState([]); | |
const [loading, setLoading] = useState(false); | |
useEffect(() => { | |
setLoading(true); | |
const timer = setTimeout(() => { | |
setVideos(dummyData); | |
setLoading(false); | |
}, 2000); | |
return () => clearTimeout(timer); | |
}, []); | |
return ( | |
<div className="App"> | |
{ | |
videos.map((list, index) => { | |
return ( | |
<section key={index}> | |
<h2 className="section-title">{list.section}</h2> | |
<CardList list={list} /> | |
<hr /> | |
</section> | |
); | |
})} | |
</div> | |
); | |
}; | |
export default App; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment