is there a way to display a default message when the date passed to Moment is invalid?
<Moment fromNow>not-a-date</Moment>
I´m getting Invalid Date.
Tage a look Check if date is a valid one
you should not use moment as jsx element, it is an normal class.
getDate() {
if (!this.props.date || check for invalid date) {
return "Alternative Message on Invalid date"
}
return <Moment fromNow>{this.props.date}</Moment>
}
render() {
return this.getDate()
}
getDate() {
if (!this.props.date || this.props.date===" " || check for invalid date criteria)
{
return "Alternative Message on Invalid date"
}
return <Moment fromNow>{this.props.date}</Moment>
}
render() {
return this.getDate()
}