Skip to content

Commit

Permalink
Fix "ReferenceError: HTMLElement is not defined" error
Browse files Browse the repository at this point in the history
  • Loading branch information
wojtekmaj committed Jul 28, 2023
1 parent a15b38b commit d2836b7
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/TimeRangePicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ import type {
Value,
} from './shared/types.js';

const isBrowser = typeof document !== 'undefined';

const baseClassName = 'react-timerange-picker';
const outsideActionEvents = ['mousedown', 'focusin', 'touchstart'] as const;
const allViews = ['hour', 'minute', 'second'] as const;
Expand Down Expand Up @@ -478,7 +480,7 @@ TimeRangePicker.propTypes = {
onClockOpen: PropTypes.func,
onFocus: PropTypes.func,
openClockOnFocus: PropTypes.bool,
portalContainer: PropTypes.instanceOf(HTMLElement),
portalContainer: isBrowser ? PropTypes.instanceOf(HTMLElement) : undefined,
rangeDivider: PropTypes.node,
required: PropTypes.bool,
secondAriaLabel: PropTypes.string,
Expand Down

0 comments on commit d2836b7

Please sign in to comment.