Home > front end >  How to solve Invalid Hook Call error when using Material UI?
How to solve Invalid Hook Call error when using Material UI?

Time:02-10

I'm new at coding and I'm having the following error when adding a MaterialUI Icon

import PersonIcon from '@mui/icons-material/Person';


function Header() {
    return (

<div>
<PersonIcon />
<h2>Header file</h2>



</div>

    );
}

export default Header;


When adding I get the following error:

Console Error when adding

Please notice that I have installed MaterialUI Core and also MaterialUI Icons When not adding everything works fine

CodePudding user response:

Try this

npm uninstall @material-ui/core @material-ui/icons

Then

npm i @material-ui/core @material-ui/icons

Restart the React server

npm start
// OR
yarn start

Let me know if it works, Good Luck

  •  Tags:  
  • Related