react-static-boilerplate icon indicating copy to clipboard operation
react-static-boilerplate copied to clipboard

Webpack problem with React-Bootstrap

Open Flaminiat opened this issue 4 years ago • 4 comments

Hello, I have been trying to add React-Bootstrap but when trying to import components I get this error below, and could not find a solution. Any idea on how to fix it? Thank you

ThemeProvider.js:3 Uncaught TypeError: __WEBPACK_IMPORTED_MODULE_1_react___default.a.createContext is not a function at Object. (ThemeProvider.js:3) at webpack_require (bootstrap 9cf716ebd281a04f8f96:659) at fn (bootstrap 9cf716ebd281a04f8f96:85) at Object. (Button.js:1) at webpack_require (bootstrap 9cf716ebd281a04f8f96:659) at fn (bootstrap 9cf716ebd281a04f8f96:85) at Object. (index.js:4) at Object. (App.js:135) at webpack_require (bootstrap 9cf716ebd281a04f8f96:659) at fn (bootstrap 9cf716ebd281a04f8f96:85)

Flaminiat avatar Jul 14 '20 12:07 Flaminiat

Hey @Flaminiat

I'm guessing the version of React that's getting imported is older and doesn't support createContext. I don't remember when it was added, but this method wasn't always available.

iansinnott avatar Jul 17 '20 04:07 iansinnott

ok thanks for your answer.

Flaminiat avatar Jul 20 '20 07:07 Flaminiat

I'm having the same issue here, and this is my package.json

{
  "name": "virtual_gallery",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "bootstrap": "^4.3.1",
    "jquery": "3.3.1",
    "react": "^16.4.0",
    "react-bootstrap": "^1.5.2",
    "react-dom": "^16.4.0",
    "react-router-bootstrap": "^0.24.4",
    "react-router-dom": "^4.2.2",
    "react-scripts": "^1.1.5",
    "reactstrap": "^6.3.0",
    "rimraf": "^2.6.2"
  },
  "devDependencies": {
    "ajv": "^6.0.0",
    "babel-eslint": "^7.2.3",
    "cross-env": "^5.2.0",
    "eslint": "^4.1.1",
    "eslint-config-react-app": "^2.1.0",
    "eslint-plugin-flowtype": "^2.50.3",
    "eslint-plugin-import": "^2.14.0",
    "eslint-plugin-jsx-a11y": "^5.1.1",
    "eslint-plugin-react": "^7.11.1"
  },
  "eslintConfig": {
    "extends": "react-app"
  },
  "scripts": {
    "start": "rimraf ./build && react-scripts start",
    "build": "react-scripts build",
    "test": "cross-env CI=true react-scripts test --env=jsdom",
    "eject": "react-scripts eject",
    "lint": "eslint ./src/"
  }
}

DiazRock avatar Mar 24 '21 21:03 DiazRock

I changed react and react-dom to dev dependencies and it works. And I'm using version 17.0.2 of each of them.

DiazRock avatar Mar 24 '21 21:03 DiazRock