[BUG-15257]Perspective Table not accepting date column

When passing a script output to a table, I get an error if one of the columns contains a date object. The error in the Output Console is

16:10:00.182 [Browser Events Thread] INFO Perspective.Designer.BrowserConsole - Invariant Violation: Minified React error #31; visit https://reactjs.org/docs/error-decoder.html?invariant=31&args[]=Thu%20Oct%2031%202019%2019%3A45%3A00%20GMT-0400%20(Eastern%20Daylight%20Time)&args[]= for the full message or use the non-minified dev environment for full errors and additional helpful warnings. 
16:10:00.183 [Browser Events Thread] INFO Perspective.Designer.BrowserConsole - ui.ErrorBoundary: Component error caught in error boundary: undefined

The URL in the error decodes the error as “Objects are not valid as a React child (found: Thu Oct 31 2019 19:45:00 GMT-0400 (Eastern Daylight Time)).”

If I get the string format of the date first, it works fine. But this date is a field of an object which can also be used to populate a DateTime Picker, and that component does not accept strings. Is there some data type which both will accept and format as a date?

The date property type is new and it looks like the table component has not been updated to handle the type. I’ll make an internal ticket for this and link it to this post.

As for a datatype that both the table and datetime picker can use, long types will work. If you have a Date object in a script, you can call date.getTime() and it will return that date as a long. The datetime picker with automatically convert the long on the front end. The table on the other hand, you will have to go into its props.columns property and add an object for the date field and set its render property to date.

Great news, thank you. And if we need to use this in production before the fix comes in, we’ll use the date.getTime().

This issue will be fixed in 8.0.6.

1 Like