React-modal: Error importing react-modal

Created on 16 Jun 2017  路  10Comments  路  Source: reactjs/react-modal

Summary:

I tried to add react-modal to my project and I'm getting this error:

Module parse failed: /node_modules/react-modal/lib/components/Modal.js Unexpected token (36:19)
You may need an appropriate loader to handle this file type.
| 
|   /* eslint-disable react/no-unused-prop-types */
|   static propTypes = {
|     isOpen: PropTypes.bool.isRequired,
|     style: PropTypes.shape({

Steps to reproduce:

  1. yarn add react-modal
  2. Add this statement at the top of my code: import Modal from 'react-modal'

Expected behavior:

Modal should not cause an error when importing

Additional notes:

I tried deleting my node_modules folder and running yarn but that didn't seem to fix the issue

```

bug

Most helpful comment

Is this not because main in package.json is "./lib/index.js" and should be "./dist/react-modal.min.js"?

As importing the module is currently returning the source code and not the transpiled code.

All 10 comments

Yeah it seems like the code is not compiled correctly.

Same for me.

hmm, I thought babel-preset-stage-2 was enough for this.
A PR to fix this would change from stage-2 to latest.
I'll be back in a few minutes.

Is this not because main in package.json is "./lib/index.js" and should be "./dist/react-modal.min.js"?

As importing the module is currently returning the source code and not the transpiled code.

Sorry for the inconvenience. I just had to push forward to get v2.0.0 and fix our repository, but I probably forgot to push an important commit from the old master (now branch v2).
@danhayden you are right.

See PR #417, @ajfuller is already working on this.

Please, use v1.9.7 until we fix this issue.

Thank you all!

Same issue, but work with v1.9.7 in Meteor project.

Released v2.0.1.

Fix for me. Thank you @diasbruno !

@LeG3nDz Thank you. Also, a fix to removed all prop-types warnings was released in v2.0.2.

@diasbruno Yep, prop-types warning are removed in v2.0.2.

Thank you ;)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

istok20 picture istok20  路  3Comments

ChristopherVH picture ChristopherVH  路  3Comments

petertdinh picture petertdinh  路  4Comments

dragonball9816 picture dragonball9816  路  3Comments

yaoyao1024 picture yaoyao1024  路  3Comments