-
Notifications
You must be signed in to change notification settings - Fork 116
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
fix(archive): Fix blank screen when sorting #1153
Conversation
mickr
commented
Jan 16, 2020
- Add try/catch handler for exceptions
- Handle case when sorting data is falsy
* Add try/catch handler for exceptions * Handle case when sorting data is falsy
Verified that @mickr has signed the CLA. Thanks for the pull request! |
if (typeof a[sortBy] === 'number' && typeof b[sortBy] === 'number') { | ||
return a[sortBy] - b[sortBy]; | ||
} | ||
try { |
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.
It seems like we should be able to guard against pretty much any issues without resorting to try/catch here. I think we should add a componentDidCatch
to the parent component, though.
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.
I think we are safe as well, but I through it in for good measure to ensure we always get an itemList returned.
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.
Ideally, try/catch should be reserved for exception handling rather than for flow control. I don't think it hurts in this case, but it can get overused.
3b69845
to
8daf600
Compare
8daf600
to
e8755db
Compare
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.
We should probably add a test case with some bad data to validate these new code branches.
* Remove try/catch * Add test for comparing to null values in the sort
I will follow this up with a |