The isDate function from date-fns is used to check whether a value is a valid Date object or not. To use the isDate function, follow these steps:
date-fns package via npm or yarn:46 chars6 lines
isDate function:index.tsx35 chars2 lines
isDate function to check whether a value is a valid Date object or not:index.tsx275 chars16 lines
In the example above, isDate is used to check whether date and dateString are valid Date objects. The first check will output "Valid Date object", while the second check will output "Invalid Date object", since dateString is a string, not a Date object.
gistlibby LogSnag