Created
June 29, 2019 19:25
-
-
Save jsmanifest/b97a8c2a54c808c9d2696d864460aa44 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