Add error wrapper for potential title
bug source
This commit is contained in:
parent
8f8c60d91b
commit
7ac9571ce4
1 changed files with 15 additions and 1 deletions
|
@ -182,7 +182,21 @@ export function useDebounce(
|
|||
export function usePageTitle(title, { skip = false } = {}) {
|
||||
React.useEffect(() => {
|
||||
if (skip) return;
|
||||
document.title = title ? `${title} | Dress to Impress` : "Dress to Impress";
|
||||
try {
|
||||
document.title = title
|
||||
? `${title} | Dress to Impress`
|
||||
: "Dress to Impress";
|
||||
} catch (e) {
|
||||
// I've been seeing Sentry errors that we can't read `title` of
|
||||
// undefined, with no traceback. This is the only `.title` I see in our
|
||||
// codebase, aside from unpacking props that I'm pretty sure aren't
|
||||
// null... so I'm adding this to help confirm!
|
||||
logAndCapture(
|
||||
new Error(
|
||||
`Could not set page title: ${e.message}. Document is: ${document}.`
|
||||
)
|
||||
);
|
||||
}
|
||||
}, [title, skip]);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue