I was using material UI with react in my project,and i have some troubles when it come to import the material icons,my code is copied from the material UI (version:"material-ui": "^1.0.0-beta.41", "material-ui-icons": "^1.0.0-beta.36",) docs ,just like this:
import SkipPreviousIcon from '@material-ui/icons/SkipPrevious';
import PlayArrowIcon from '@material-ui/icons/PlayArrow';
import SkipNextIcon from '@material-ui/icons/SkipNext';
and also i have run npm install material-icons. the error in my chrome console is:
./src/index/musicCard.js Module not found: Can't resolve '@material-ui/icons/PlayArrow' in 'C:\Users\wenji\Desktop\myblog\src\index' and I tried this one:
import SkipPreviousIcon from 'material-ui/icons/SkipPrevious';
and this one:
import SkipPreviousIcon from '@material-ui-icons/SkipPrevious';
but dose not make any difference,so can anyone help me ?
Icons are not part of material-ui/core so it must be install using two commands.
If you are using npm
npm install @material-ui/core
npm install @material-ui/icons
If you are using yarn
yarn add @material-ui/core
yarn add @material-ui/icons
Solved, the icons module should be added to dependencies. use npm
npm install @material-ui/icons
or use yarn
yarn add @material-ui/icons
I just solved a strange, ( but not so strange after i found out why) issue
on mac it worked but when i deploy to linux it failed and could not find the icon
this was because on mac it is not case sensitive and linux is
so
import DeleteForEver from '@material-ui/icons/DeleteForEver'
works on mac but fails on linux
the file is actually named like "DeleteForever"
so correct way to import is
import DeleteForever from '@material-ui/icons/DeleteForever'