Skip to content

Conversation

@aesopwolf
Copy link
Contributor

This enables server side rendering

This enables server side rendering
src/index.js Outdated

_keyPressPropName() {
return navigator.userAgent.match(/Android/i)
if (navigator) {
Copy link
Collaborator

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
Copy link
Collaborator

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
@iamdustan iamdustan merged commit 16990c1 into insin:master Dec 15, 2016
@iamdustan
Copy link
Collaborator

Published as 3.3.4. Thanks!

@aesopwolf aesopwolf deleted the fix/server-side-rendering branch December 15, 2016 03:13
@avindra
Copy link
Contributor

avindra commented Dec 17, 2016

@aesopwolf I would recommend mocking navigator. User agent is typically a header sent by browsers anyway, and for isomorphic code you would want navigator.userAgent to be available on the server side.

@aesopwolf
Copy link
Contributor Author

What would be the purpose of mocking navigator on the server within the context of this function? The server has no business setting up event handlers.

@avindra
Copy link
Contributor

avindra commented Dec 17, 2016

In this context of this function, it has no meaning, but other libraries could potentially be rendering different DOM attributes or altogether different subtrees. -

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.

3 participants