Skip to content

Commit d8915a8

Browse files
committed
Fix "ReferenceError: HTMLElement is not defined" error
1 parent 3a2afb1 commit d8915a8

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/DateTimePicker.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ import type {
2323
Value,
2424
} from './shared/types.js';
2525

26+
const isBrowser = typeof document !== 'undefined';
27+
2628
const baseClassName = 'react-datetime-picker';
2729
const outsideActionEvents = ['mousedown', 'focusin', 'touchstart'] as const;
2830
const allViews = ['hour', 'minute', 'second'] as const;
@@ -660,7 +662,7 @@ DateTimePicker.propTypes = {
660662
onClockOpen: PropTypes.func,
661663
onFocus: PropTypes.func,
662664
openWidgetsOnFocus: PropTypes.bool,
663-
portalContainer: PropTypes.instanceOf(HTMLElement),
665+
portalContainer: isBrowser ? PropTypes.instanceOf(HTMLElement) : undefined,
664666
required: PropTypes.bool,
665667
secondAriaLabel: PropTypes.string,
666668
secondPlaceholder: PropTypes.string,

0 commit comments

Comments
 (0)