yocontra / react-responsive

CSS media queries in react - for responsive design, and more.
https://contra.io/react-responsive
MIT License
7.04k stars 298 forks source link

.a.useContext is not a function #238

Closed williamgoodhew closed 4 years ago

williamgoodhew commented 4 years ago

I am getting the following error in when using the useMediaQuery({ minDeviceWidth: 1224 })

__WEBPACK_IMPORTED_MODULE_0_react___default.a.useContext is not a function at useDevice (react-responsive.js:75) at useMediaQuery (react-responsive.js:110)

I was getting the error when my React and React-Dom versions were 16.4.0. After looking at the following issues.

https://stackoverflow.com/questions/54101839/react-default-usecontext-is-not-a-function https://github.com/mui-org/material-ui/issues/14075

I updated my React and React-dom versions to 16.8.0 to ensure that I had the correct version of React to support webhooks.

I am still however getting the same error.

Here is my package.json

{ "name": "athalens_website", "version": "0.1.0", "private": true, "dependencies": { "@material-ui/core": "^3.9.2", "@material-ui/icons": "^3.0.2", "firebase": "^5.4.2", "lodash": "^4.17.11", "prop-types": "^15.6.2", "react": "^16.8.0", "react-awesome-modal": "^2.0.5", "react-dom": "^16.8.0", "react-ga": "^2.5.7", "react-instantsearch": "^5.3.2", "react-redux": "^5.0.7", "react-responsive": "^8.0.1", "react-router-dom": "^4.3.1", "react-router-ga": "^1.1.0", "react-scripts": "^1.1.5", "reactjs-spinner": "^2.0.0", "redux": "^4.0.0", "redux-thunk": "^2.3.0", "typeface-roboto": "0.0.54" }, "scripts": { "start": "react-scripts start", "build": "react-scripts build", "test": "react-scripts test --env=jsdom", "eject": "react-scripts eject" } }

yocontra commented 4 years ago

I would still guess your react versions aren't aligned - check the output of yarn why react + yarn why react-dom and make sure you have no other versions present, and running yarn upgrade to rebuild your node_modules wouldn't hurt either. If you don't use yarn then the npm equivalent commands that do the same.

yocontra commented 4 years ago

Closing since I haven't gotten a response.