Home > Blockchain >  Facing error while using materisl-ui icons in react app
Facing error while using materisl-ui icons in react app

Time:07-11

I have used the commands npm install @material-ui/core and npm install @material-ui/icons in my react app and want to use the FileUploadIcon. I am importing it by using

import { FileUploadIcon } from '@material-ui/icons/FileUpload';

and later

<input type= "file" id = "file" onChange={checkJSON}/>
<label for = "file">
<FileUploadIcon />
    Choose a JSON file
</label>'

I am getting the error

Module not found: Can't resolve '@material-ui/icons/FileUpload' in 'F:\Profile\Desktop\New\UI\react-jwt-auth-master\src\components'

My package.json has these dependencies

"@material-ui/core": "^4.12.4",
"@material-ui/icons": "^4.11.3",

CodePudding user response:

You can use the search here to see which icons are part of @material-ui/icons: https://material-ui.com/components/material-icons/. FileUploadIcon is not there.

If you have the svg for an icon such as from the material.io site, you can create an SvgIcon element by grabbing the path element from the svg:

Please refer this link: Module not found: Can't resolve '@material-ui/icons/ContentCut'

CodePudding user response:

icon import code needs to be changed

change this code

import { FileUploadIcon } from '@material-ui/icons/FileUpload';

like this

import { FileUploadIcon } from '@material-ui/icons';

a solution to this question will help us

How do I upload Icons from material-ui?

  • Related