reactjs / react-modal

Accessible modal dialog component for React
http://reactcommunity.org/react-modal
MIT License
7.37k stars 808 forks source link

ReferenceError: exports is not defined #768

Open Zorig opened 5 years ago

Zorig commented 5 years ago

Summary:

i am using react-modal 3.9.1 with typescript: 3.3.3 with nextjs 9 and when importing ReactModal it is giving me an error saying "ReferenceError: exports is not defined" i also used @types/react-modal:3.8.2. on a sandbox it is working without issue though. But still there is error saying Module '"/sandbox/node_modules/@types/react-modal/index"' has no default export.ts(1192)

  1 | "use strict";
  2 | 
> 3 | Object.defineProperty(exports, "__esModule", {
  4 |   value: true
  5 | });
  6 | exports.bodyOpenClassName = exports.portalClassName = undefined;

Steps to reproduce:

  1. Install React-modal latest veersion on react typescript project
  2. Import ReactModal from 'react-modal'
  3. Call <ReactModal> in render method

Expected behavior:

should work without issue

Link to example of issue:

https://codesandbox.io/embed/tender-leavitt-260ul

Additional notes:

martindidiego commented 5 years ago

I noticed the same issue in my TypeScript project using @types/react-modal@3.8.2. I worked around it by importing it with require:

import ReactModal = require('react-modal')
diasbruno commented 5 years ago

@martindidiego @Zorig Can you investigate if this issue is related react-modal?

nickserv commented 5 years ago

It's possible that @types/react-modal (in DefinitelyTyped) needs to add ES module types for this package