Skip to content

Instantly share code, notes, and snippets.

@mohnatus
Created April 25, 2020 18:38
Show Gist options
  • Save mohnatus/e60581b40fef176b605c91fc7ce1524d to your computer and use it in GitHub Desktop.
Save mohnatus/e60581b40fef176b605c91fc7ce1524d to your computer and use it in GitHub Desktop.
Skeleton screens (React)
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