Skip to content

Commit

Permalink
Add setLoading function to toggle rendering of the LoadingSpinner com…
Browse files Browse the repository at this point in the history
…ponent.

Refactored LoadingSpinner component to display under the Latest Opportunities heading to reflect more the intent of the loading spinner.
  • Loading branch information
saramccombs authored and saramccombs committed Jul 28, 2020
1 parent 67b2439 commit 02b11f0
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/pages/Home.js
Expand Up @@ -10,7 +10,7 @@ import LoadingSpinner from '../components/LoadingSpinner'

const Home = () => {
const [jobs, setJobs] = useState([])
const [loading] = useState(true)
const [loading, setLoading] = useState(true)

useEffect(() => {
;(async function retrieveJobs() {
Expand All @@ -35,6 +35,7 @@ const Home = () => {
}
})
setJobs(jobList)
setLoading(false)
})()
}, [])

Expand Down Expand Up @@ -78,8 +79,6 @@ const Home = () => {
learn.
</p>

<LoadingSpinner loading={loading}/>

<button className='btn btn-teal mx-auto'>
<Link to='/job-board'>Find a Job</Link>
</button>
Expand All @@ -103,6 +102,8 @@ const Home = () => {
Latest Opportunities
</h2>

<LoadingSpinner loading={loading}/>

<div data-cy='job-card-container' className='container'>
{jobs.slice(0, 6).map((job, index) => (
<JobCard key={job.id} job={job} />
Expand Down

0 comments on commit 02b11f0

Please sign in to comment.