iansinnott / react-static-boilerplate

A boilerplate for building static sites with Webpack 2, React and React Router
107 stars 16 forks source link

Webpack problem with React-Bootstrap #23

Open Flaminiat opened 4 years ago

Flaminiat commented 4 years ago

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)

iansinnott commented 4 years ago

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.

Flaminiat commented 4 years ago

ok thanks for your answer.

DiazRock commented 3 years ago

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 commented 3 years ago

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