Created
July 3, 2019 16:04
-
-
Save jsmanifest/148512497270cf7797962480d1327278 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 SomeComponent = ({ items = [], todaysDate, tomorrowsDate }) => { | |
const [someState, setSomeState] = useState(null) | |
return ( | |
<div> | |
<h2>Today is {todaysDate}</h2> | |
<small>And tomorrow is {tomorrowsDate}</small> | |
<hr /> | |
{items.map((item, index) => ( | |
<span key={`item_${index}`}>{item.email}</span> | |
))} | |
</div> | |
) | |
} | |
const App = ({ dates, ...otherProps }) => { | |
let items | |
if (dates) { | |
items = dates ? dates.map((d) => new Date(d).toLocaleDateString()) : null | |
} | |
return ( | |
<div> | |
<SomeComponent {...otherProps} items={items} /> | |
</div> | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I think you made a mistake having the dates ternary inside
if(dates)