Skip to content

Instantly share code, notes, and snippets.

@jsmanifest
Created June 29, 2019 19:25
Show Gist options
  • Save jsmanifest/b97a8c2a54c808c9d2696d864460aa44 to your computer and use it in GitHub Desktop.
Save jsmanifest/b97a8c2a54c808c9d2696d864460aa44 to your computer and use it in GitHub Desktop.
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