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
[Web] Checking window
before accessing
#646
Conversation
window
before accessing
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 with typescript optional chaining, it can be simpler. What do you think?
Co-authored-by: Mike Hardy <github@mikehardy.net>
Co-authored-by: Mike Hardy <github@mikehardy.net>
Co-authored-by: Mike Hardy <github@mikehardy.net>
Co-authored-by: Mike Hardy <github@mikehardy.net>
Co-authored-by: Mike Hardy <github@mikehardy.net>
For some reason, optional chaining is not working when Next transpiles the module, so reverted to using an expression to check for |
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.
as mentioned in direct comment - really surprising on the optional chaining failure but there is nothing like an experimental result and you have conducted the experiment. So just one tiny detail I think ?
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.
As mentioned - still surprising the optional chain doesn't work, but a tested result is more important than a hypothesis, and it sounds like this code works and has same return types. Fantastic. Thanks for posting this up and checking through it
Co-authored-by: Mike Hardy <github@mikehardy.net>
## [9.3.7](v9.3.6...v9.3.7) (2022-11-28) ### Bug Fixes * **web:** check `window` is defined before accessing ([#646](#646)) ([ba5c22c](ba5c22c))
🎉 This PR is included in version 9.3.7 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Overview
Solving #645
Add checks to web version of NetInfo to avoid trying to access properties of
undefined
. This scenario can occur when using this package with Server Side Rendering (SSR).Test Plan
After adding these, I was able to build the Next.js app.