Skip to content

Commit

Permalink
fix: ensure datepicker can be used in SSR environments
Browse files Browse the repository at this point in the history
  • Loading branch information
bryanjos committed Jan 30, 2020
1 parent 6636372 commit 72b1f6d
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/DatePicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ function goodDateInput() {
*/

const isFirefox = () => {
return /Firefox/i.test(navigator.userAgent)
return (
typeof navigator !== 'undefined' && /Firefox/i.test(navigator.userAgent)
)
}

/** A DatePicker component containing inputs and a calendar. */
Expand Down Expand Up @@ -189,7 +191,7 @@ class UncontrolledDatePicker extends React.Component {
// Force the input to be focused again (so that we don't immediately close
// the calendar because the button click makes us not focused on the input)
this.refocus()
});
})
}

/**
Expand Down

0 comments on commit 72b1f6d

Please sign in to comment.