Skip to content

Draggable is undefined with normal import syntax in TypeScript #266

Description

@cainlevy

(first reported in #246)

Error

ES6 import syntax fails when TypeScript is configured with "module": "commonjs":

import Draggable from 'react-draggable'

The error message is visible at runtime, when React says:

type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: undefined

This error can be confirmed with console.log(Draggable), which prints undefined.

Workaround

Use the commonjs import syntax:

const Draggable = require('react-draggable');

Version

react-draggable@2.2.6

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions