-
Notifications
You must be signed in to change notification settings - Fork 405
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
Prevent JSON parse error #827
Conversation
Users can pass in `{ enabled: true }` as the sortOptions, which means `initialSortBy` would be `undefined` and `JSON.parse` throws an error when you hand it `undefined`. So we need to default the value if it is not present.
@@ -1582,7 +1582,7 @@ export default { | |||
|
|||
initializeSort() { | |||
const { enabled, initialSortBy, multipleColumns } = this.sortOptions; | |||
const initSortBy = JSON.parse(JSON.stringify(initialSortBy)); | |||
const initSortBy = JSON.parse(JSON.stringify(initialSortBy || {})); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If initialSortBy
is undefined
default to an empty object to prevent JSON.parse(undefined)
error from throwing.
@xaksis Updating to the latest version and most of my tests broke with super cryptic error messages. Took a while to track this down, but it was a very easy fix. |
I came to dig into this same issue. Thanks for fixing it. |
Thanks @TheJaredWilcurt ! |
Users can pass in
{ enabled: true }
as the sortOptions, which meansinitialSortBy
would beundefined
andJSON.parse
throws an error when you hand itundefined
. So we need to default the value if it is not present.