Skip to content

Commit 16990c1

Browse files
aesopwolfiamdustan
authored andcommitted
add check for navigator (insin#83)
* 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
1 parent ffae092 commit 16990c1

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/index.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,9 +236,12 @@ var MaskedInput = React.createClass({
236236
},
237237

238238
_keyPressPropName() {
239-
return navigator.userAgent.match(/Android/i)
239+
if (typeof navigator !== 'undefined') {
240+
return navigator.userAgent.match(/Android/i)
240241
? 'onBeforeInput'
241242
: 'onKeyPress'
243+
}
244+
return 'onKeyPress'
242245
},
243246

244247
_getEventHandlers() {

0 commit comments

Comments
 (0)