Skip to content
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

Serverside rendering broken by navigator access in Input.js #323

Closed
jorrit opened this issue Nov 30, 2020 · 2 comments
Closed

Serverside rendering broken by navigator access in Input.js #323

jorrit opened this issue Nov 30, 2020 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@jorrit
Copy link
Contributor

jorrit commented Nov 30, 2020

Since 8.0.4 I can't build my application because of the following error:

ReferenceError: navigator is not defined
at Object. (node_modules\react-date-picker\dist\DateInput\Input.js:25:20)

This broke in commit 7c6af9d.

I see two solutions:

  1. prefix navigator.userAgent... with typeof navigator !== 'undefined' && .
  2. Move navigator.userAgent.match(/ Edge\/1/) to the if statement in onFocus().
@wojtekmaj
Copy link
Owner

wojtekmaj commented Nov 30, 2020

Thanks for reporting.

Ad 1 - actually window can be undefined in some envs as well. I think the best approach would be:

const isEdgeLegacy = (
  typeof window !== 'undefined' && 'navigator' in window
  && navigator.userAgent.match(/ Edge\/1/)
);

@wojtekmaj wojtekmaj self-assigned this Nov 30, 2020
@wojtekmaj wojtekmaj added the bug Something isn't working label Nov 30, 2020
@wojtekmaj
Copy link
Owner

v8.0.5 released. Thanks again

wojtekmaj added a commit that referenced this issue Jan 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants