Skip to content

Commit

Permalink
add check for navigator (#83)
Browse files Browse the repository at this point in the history
* add check for navigator

This enables server side rendering

* fix eslint errors

* changes per feedback

`typeof navigator !== 'undefined'` otherwise strict mode will still throw
`return 'onKeyPress'` as a fallback in case someone is removing navigator from the global scope
  • Loading branch information
aesopwolf authored and iamdustan committed Dec 15, 2016
1 parent ffae092 commit 16990c1
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -236,9 +236,12 @@ var MaskedInput = React.createClass({
},

_keyPressPropName() {
return navigator.userAgent.match(/Android/i)
if (typeof navigator !== 'undefined') {
return navigator.userAgent.match(/Android/i)
? 'onBeforeInput'
: 'onKeyPress'
}
return 'onKeyPress'
},

_getEventHandlers() {
Expand Down

0 comments on commit 16990c1

Please sign in to comment.