Search code examples
reactjsmodal-dialogreact-modal

use react-modal error: Uncaught TypeError: Cannot read property 'ReactCurrentOwner' of undefined


working on a react-lite project, I also installed react. Want to use react-modal to create a window when clicking a button. can not work.

Error is Uncaught TypeError: Cannot read property 'ReactCurrentOwner' of undefined.

I tried reinstall node_modules, and npm install, update, not working.Package.json:

"devDependencies": {
    "babel-core": "^6.25.0",
    "babel-loader": "^7.0.0",
    "babel-plugin-transform-react-jsx": "^6.24.1",
    "babel-preset-env": "^1.5.2",
    "chrome-remote-interface": "^0.25.5",
    "compression-webpack-plugin": "~1.0.0",
    "copy-webpack-plugin": "~3.0.1",
    "css-loader": "^0.28.11",
    "eslint": "^3.19.0",
    "eslint-loader": "^1.9.0",
    "eslint-plugin-react": "~6.9.0",
    "extract-text-webpack-plugin": "^2.1.0",
    "htmlparser": "^1.7.7",
    "jed": "^1.1.1",
    "jshint": "^2.9.5",
    "jshint-loader": "^0.8.4",
    "less": "^3.8.0",
    "less-loader": "^4.1.0",
    "po2json": "^0.4.5",
    "sass-loader": "^7.0.3",
    "sizzle": "^2.3.3",
    "stdio": "^0.2.7",
    "webpack": "^2.6.1"
  },
  "dependencies": {
    "bootstrap": "^4.1.1",
    "bootstrap-less": "^3.3.8",
    "exenv": "^1.2.2",
    "jquery": "^3.3.1",
    "moment": "^2.22.2",
    "node-sass": "^4.9.0",
    "patternfly": "^3.52.2",
    "prop-types": "^15.6.2",
    "react": "^16.0.0",
    "react-addons-css-transition-group": "^15.6.2",
    "react-addons-transition-group": "^15.6.2",
    "react-dom": "^16.0.0",
    "react-lite": "^0.15.38",
    "react-modal": "^2.2.2",
    "reactstrap": "^6.3.0",
    "strict-loader": "^1.2.0"
  }
}

Solution

  • I see you're using React 16.x.

    Check the react-lite NPM page here

    Note: react-lite dose not support React v16.x now.

    This may be your issue.

    I don't know the scope of your project, or what you're trying to accomplish, but you may find Preact to be a good alternative.