Created
April 9, 2018 15:17
-
-
Save rockymeza/503c4b2343982bbaf88753b2369a99d8 to your computer and use it in GitHub Desktop.
Pure implementation of WeekendStatus
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 * as React from 'react'; | |
const WeekendStatus = ({ currentTime }) => { | |
// Because we take currentTime as a prop, we now no longer depend | |
// on the external system time in our render function. We are now | |
// a pure function | |
const dayOfWeek = new Date(currentTime).getDay(); | |
const isWeekend = [0, 6].includes(dayOfWeek); | |
if (isWeekend) { | |
return <p>It's the weekend!</p>; | |
} | |
return <p>It is not the weekend. :(</p>; | |
}; | |
export default WeekendStatus; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment