Replies: 1 comment 6 replies
-
Shouldn't condition be without negation before isValid, like |
Beta Was this translation helpful? Give feedback.
6 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi community, thanks for your great contribution. I'm using date-fns to convert ISO dates from my mongoDB database. The problem is that not every document have the date object which causes RangeError: Invalid time value error on my react app.
I'm displaying the documents using react table and tried to exclude documents which do not have a date object.
const columns = useMemo( () => [ { Header: "All companies", columns: [ { Header: "Founding Date", accessor: "companyFoundationDate", Cell: ({ value }) => { if(!isValid(value) && value !== 'NaN') { return format(new Date(value), 'MM/yyyy') } } }, ] }, ], [] );
However, this does not work and continues to throw the same error without the if statement. I'm thinking that it's because the if statement doesn't work here. Do you think you can help me improve this?
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions