Skip to content

Conversation

@STRML
Copy link
Collaborator

@STRML STRML commented Jan 2, 2026

Fixes #251

Summary

The draggableOpts.offsetParent prop type used PropTypes.instanceOf(Element) which throws a ReferenceError: Element is not defined in SSR/Node.js environments where the DOM global Element doesn't exist.

This was likely introduced when the draggableOpts prop type shape was expanded to include offsetParent. The fix checks if Element is defined before using instanceOf, falling back to PropTypes.any in SSR environments.

Fix

Changed in lib/propTypes.js:

offsetParent: typeof Element !== 'undefined' ? PropTypes.instanceOf(Element) : PropTypes.any,

Test plan

  • Test fails without fix (verified with @jest-environment node)
  • Test passes with fix
  • All tests pass
  • Lint passes

The `draggableOpts.offsetParent` prop type used `PropTypes.instanceOf(Element)`
which throws a ReferenceError in SSR/Node.js environments where the DOM global
`Element` doesn't exist.

This was introduced in a prior release that added the draggableOpts prop type
definitions. The fix checks if Element is defined before using instanceOf.
@github-actions
Copy link

github-actions bot commented Jan 2, 2026

No changes in the dependency files were detected.

@STRML STRML merged commit af0d739 into master Jan 2, 2026
3 checks passed
@STRML STRML deleted the fix/issue-251-ssr-element branch January 2, 2026 01:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Element is not available in some environments v3.1.0

2 participants