Topic: Error: Material-UI: react@16.3.0 or greater is required.

mattagape pro asked 5 years ago


Expected behavior

When I do require("mdbreact"), I expect to get mdbreact

Actual behavior

Instead I get this console error: Error: Material-UI: react@16.3.0 or greater is required.

Resources (screenshots, code snippets etc.)

My app is built using Gatsby.js, v1.9.247. This Gatsby version (which I am not able to upgrade without some major refitting) has react v15.6.0 baked into it -- thus I am not able to upgrade my React version to the 16.3.0 version demanded in the console error.

Do I need to downgrade my version of mdbreact to a version lower than 4.20.0? (which it is now) If I need to downgrade mdbreact in order to accommodate my older version of react, how can I do so? If I try to run...

$ yarn add mdbreact@4.8.0

... I end up with "mdbreact": "4.8.0" in package.json which makes my "MDB pro" functionality inaccessible.

Any help on this would be much appreciated. Thanks!


mattagape pro commented 5 years ago

I couldn't figure it out so I did a...

$ git fetch --all

$ git reset --hard origin/master

...from my repo. I still don't know what the problem was, but at least the error has gone away.


mattagape pro commented 5 years ago

It might be nice if MDBReact could show us how to easily change local versions of it. In my case version 4.8.2 worked, but 4.20.0 broke my app.


mattagape pro commented 5 years ago

I think my problem was that I'd deleted yarn.lock before (while also deleting .cache & node_modules folders). Then when I ran $ yarn, MDBReact automatically installed its latest version of 4.20.0. I guess I need to refrain from deleting yarn.lock in order to keep my [working] 4.8.2 version of MDBReact.


Konrad Stępień staff answered 5 years ago


Hi @mattagape,

My package.json file has these dependencies:

"dependencies": {
    "@svgr/webpack": "^4.1.0",
    "gatsby": "^2.0.76",
    "gatsby-image": "^2.0.20",
    "gatsby-plugin-manifest": "^2.0.9",
    "gatsby-plugin-offline": "^2.0.16",
    "gatsby-plugin-react-helmet": "^3.0.2",
    "gatsby-plugin-sharp": "^2.0.14",
    "gatsby-plugin-svgr": "^2.0.1",
    "gatsby-source-filesystem": "^2.0.8",
    "gatsby-transformer-sharp": "^2.1.8",
    "mdbreact": "4.20.0",
    "prop-types": "^15.6.2",
    "react": "^16.9.0",
    "react-dom": "^16.9.0",
    "react-helmet": "^5.2.0",
    "react-router-dom": "^5.0.1"
},

And everything works correctly.

If you need we can send you MDBreact with other versions.

it's possible that versions between gatsby and MDBreact should be updated to the newest so that everything doesn't conflict with each other.

Also, we in the next update remove Material-UI from our package. Maybe the error is from here.

Please copy your repo and then try to set :

"mdbreact": "4.20.0", //or import your pro version
"react": "^16.9.0",
"react-dom": "^16.9.0",

then delete yarn.lock, node modules, and package-lock.json. and run npm i,

Please tell me if you have news for this issue. Thanks.

Best regards, Konrad.



Please insert min. 20 characters.

FREE CONSULTATION

Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.

Status

Answered

Specification of the issue

  • ForumUser: Pro
  • Premium support: No
  • Technology: MDB React
  • MDB Version: 4.20.0
  • Device: Macbook
  • Browser: Chrome
  • OS: OSX
  • Provided sample code: Yes
  • Provided link: No