-
Notifications
You must be signed in to change notification settings - Fork 8
Open
Labels
bugSomething isn't workingSomething isn't working
Description
The usePageErrors hook correctly checks the result as an instance of a ResultRecord to pull out error messages and returns early. However, result can come from anywhere - in cases where it is an Error thrown, the array that we are returning as pageErrors is no longer a string array - it might be a [Error, string] or objects of any other shape. This can cause issues when mapping out what consumers expect to be an array of plain strings to JSX.
Example of React error in development when an Error is thrown and caught by handlePageLoadError, then mapped in an unordered list
Add a safe guard to check for a string or otherwise try to coalesce the object into a string:
if (typeof result === "string") {
setPageErrors((errors: string[]) => [...errors, result]);
return;
}
setPageErrors((errors: string[]) => [...errors, result.toString()]);Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working
