Created
February 18, 2020 20:51
-
-
Save Kristian-Roopnarine/262f7cbdc79c1eb7e1466bbede9035b7 to your computer and use it in GitHub Desktop.
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
const Projects = () => { | |
const [projectInfo,setProjectInfo] = useState([]); | |
const fetchProjects = async () =>{ | |
const response = await projects.get('/projects/') | |
setProjectInfo(response.data) | |
} | |
const createProjectCards = () => { | |
return( | |
<div className="ui three stackable raised cards"> | |
{projectInfo.map(project => { | |
if(!project){ | |
return <div>Loading..</div> | |
} else { | |
return ( | |
<ProjectCard | |
name={project.name} | |
description = {project.description} | |
image={project.image} | |
github={project.github} | |
demo={project.demo} | |
key={project.name} | |
/> | |
) | |
} | |
})} | |
</div> | |
) | |
} | |
useEffect(()=>{ | |
fetchProjects() | |
},[]) | |
return ( | |
<> | |
<div className="ui center aligned container"> | |
<h1>Projects</h1> | |
</div> | |
{createProjectCards()} | |
</> | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment