-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
remove typeof undefined checks where not necessary 🐃🪒 #1726
Conversation
size-limit report 📦
|
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit 3bd595b:
|
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.
Overall looks good to me, just a quick question about the ismorphic layout effect check.
export const useIsomorphicLayoutEffect = | ||
typeof window !== 'undefined' && | ||
typeof window.document !== 'undefined' && | ||
typeof window.document.createElement !== 'undefined' | ||
window.document && | ||
window.document.createElement | ||
? useLayoutEffect | ||
: useEffect |
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.
Can this be even shorter? It looks like there are many implementations that are just:
typeof document !== 'undefined' ? useLayoutEffect : useEffect
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.
Hmm. I would normally say "those other implementations are probably wrong", but Andarist normally knows what he's doing.
I'm going to say leave this alone - it's there, we know it works.
f1ed0e4
to
3bd595b
Compare
✅ Deploy Preview for redux-starter-kit-docs ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
This is just a bit of yak shaving, but I noticed we are doing the
typeof x === 'undefined'
check in quite some places where we would not need to. I changed it tox === undefined
(orx == null
if there was anx === null
check going on in parallel anyways).I kept the behaviour for non-local variables like
window
,navigator
,process
andAbortController
.