Skip to content
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

Avoid Type error: 'searchParams' is possibly 'null'. in example code #56

Merged
merged 2 commits into from
May 23, 2024

Conversation

unitof
Copy link
Contributor

@unitof unitof commented May 23, 2024

Out of the box (on next@14), the app router example code fails to build with a Type error, since searchParams can be null:

./app/Fathom.tsx:25:23
Type error: 'searchParams' is possibly 'null'.
  23 |
  24 |     trackPageview({
> 25 |       url: pathname + searchParams.toString(),
     |                       ^
  26 |       referrer: document.referrer
  27 |     });
  28 |   }, [pathname, searchParams]);
Error: Command "npm run vercel-build" exited with 1

This allows for that with the optional chaining ?. operator.

@derrickreimer
Copy link
Owner

Thanks @unitof!

@derrickreimer derrickreimer merged commit 7a9b528 into derrickreimer:master May 23, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants