6
  • I am using material ui stepper.
  • I used from there site but its broken
  • so I debugged and gave console inside VerticalLinearStepper method.
  • its printting a method at this line console.log("useStyles----->", useStyles);
  • but I am facing an error _react.default.useContext is not a function
  • can you tell me how to fix it.
  • so that in future I will fix it myself.
  • providing code snippet and sandbox below

https://codesandbox.io/s/v3o3zmxk90

function VerticalLinearStepper() {
 console.log("useStyles----->", useStyles);
 const classes = useStyles();
 const [activeStep, setActiveStep] = React.useState(0);
 const steps = getSteps();
 function handleNext() {
 setActiveStep(prevActiveStep => prevActiveStep + 1);
 }
 function handleBack() {
 setActiveStep(prevActiveStep => prevActiveStep - 1);
 }
 function handleReset() {
 setActiveStep(0);
 }
asked Jan 9, 2019 at 0:53

2 Answers 2

13

@material-ui/styles has a peer dependency on react>= 16.7.0-alpha.0 and react-dom>= 16.7.0-alpha.0 Update your react and react-dom dependencies to:

"dependencies": {
 "react": "^16.7.0-alpha.2",
 "react-dom": "^16.7.0-alpha.2",
},
answered Jan 9, 2019 at 1:46
Sign up to request clarification or add additional context in comments.

1 Comment

"material-ui is deprecated use @material-ui/core instead" only to find out later that component examples for @material-ui/core include @material-ui/styles which depends on unstable version of react :(
4

From what I can see, you are using a version of React that does not yet have support for hooks (useXXX)

It sometimes confuses me too, but latest as a version in your package.json actually means "Latest stable version".
To use a version that supports hooks, you can use the version next for react as well as react-dom :)

answered Jan 9, 2019 at 1:00

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.