From 16990c1abf1c63427e1131df95c6e7575bd20f3e Mon Sep 17 00:00:00 2001 From: Aesop Wolf Date: Wed, 14 Dec 2016 18:48:50 -0800 Subject: [PATCH] add check for navigator (#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 --- src/index.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/index.js b/src/index.js index 4f26b34..7389581 100644 --- a/src/index.js +++ b/src/index.js @@ -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() {