react-modal-dialog icon indicating copy to clipboard operation
react-modal-dialog copied to clipboard

Cannot read property 'number' of undefined

Open jeffreyabarrios opened this issue 6 years ago • 5 comments

When adding the repository with yarn add react-modal-dialog, just by importing it gives this error, as if the actual _react object is undefined within the library. Any idea of why this happens?

Edit: I believe its in the way proptypes is imported.

screen shot 2017-10-26 at 5 10 19 pm

jeffreyabarrios avatar Oct 26 '17 23:10 jeffreyabarrios

Yes, proptypes have changed in React 16 and the plugin no longer works

fabricioasap avatar Oct 27 '17 19:10 fabricioasap

Any updates on this?

abeikverdi avatar Nov 02 '17 03:11 abeikverdi

Had the same issue and created a workaround with react (v16) and the prop-types package. Not the best one, but it works:

require('react').PropTypes = require('prop-types');

Alexis-Bize avatar Nov 03 '17 11:11 Alexis-Bize

still wont work

victorteokw avatar Nov 03 '17 12:11 victorteokw

@zhangkaiyulw Are you using webpack? If so:

entry.js (used in webpack):

require('react').PropTypes = require('prop-types');
require('./client.js');

client.js (Also works with requireofc)

import React from 'react'
import ReactDOM from 'react-dom'
// ...
ReactDOM.hydrate(...)

Alexis-Bize avatar Nov 03 '17 16:11 Alexis-Bize