-
Notifications
You must be signed in to change notification settings - Fork 194
add check for navigator #83
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
Conversation
This enables server side rendering
src/index.js
Outdated
|
|
||
| _keyPressPropName() { | ||
| return navigator.userAgent.match(/Android/i) | ||
| if (navigator) { |
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 you do a typeof navigator !== 'undefined' check? strict mode would still throw on this.
src/index.js
Outdated
| ? 'onBeforeInput' | ||
| : 'onKeyPress' | ||
| } | ||
| return |
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.
let’s return onKeyPress as a fallback. In case someone is doing something terribly weird and deleting or hiding navigator from the global scope.
`typeof navigator !== 'undefined'` otherwise strict mode will still throw `return 'onKeyPress'` as a fallback in case someone is removing navigator from the global scope
|
Published as 3.3.4. Thanks! |
|
@aesopwolf I would recommend mocking |
|
What would be the purpose of mocking |
|
In this context of this function, it has no meaning, but other libraries could potentially be rendering different DOM attributes or altogether different subtrees. - |
This enables server side rendering