Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

null date handling? #89

Open
squarewave24 opened this issue Mar 6, 2019 · 2 comments
Open

null date handling? #89

squarewave24 opened this issue Mar 6, 2019 · 2 comments

Comments

@squarewave24
Copy link

squarewave24 commented Mar 6, 2019

i looked at all the examples and googled for 30 minutes but can't seem to make this work if the date is optional

"moment": "^2.24.0",
"react-moment": "^0.8.4",

doing this with optional endDate field:

<Moment format="MMM DD YYYY HH:MM">
    {`${r.endDate}`}
</Moment>

error:

moment.js:299 Deprecation warning: value provided is not in a recognized RFC2822 or ISO format. moment construction falls back to js Date(), which is not reliable across all browsers and versions. Non RFC2822/ISO date formats are discouraged and will be removed in an upcoming major release. Please refer to http://momentjs.com/guides/#/warnings/js-date/ for more info.

and invalid date is written in place

i'd like to ignore null or invalid date..

@dimaqq
Copy link

dimaqq commented Apr 16, 2019

Also, <Moment fromNow>{ undefined }</Moment> is rendered as a few seconds ago 😖

@ivarprudnikov
Copy link

AFAIK react allows conditional rendering (docs):

<div>{r.endDate && <Moment format="MMM DD YYYY HH:MM">
    {`${r.endDate}`}
</Moment>}</div>

Otherwise it is hard to tell which behavior ought to happen:
a) throw when invalid argument
b) render with implied new Date
c) render nothing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants