Missing import of material-ui search icon
P粉208469050
P粉208469050 2024-04-02 13:22:44
0
2
456

import React from 'react'
import {Search} from "@material-ui/icons/Search"
const App = () => {
  return (
    <div>
    <Search/>
    </div>
  )
}
export default App

Export 'search' (imported as 'search') not found in '@material-ui/icons/Search' (possible export: __esModule, default)

Export 'search' (imported as 'search') not found in '@material-ui/icons/Search' (possible export: __esModule, default)

The search icon is not imported, but I installed the material package, but it is not displayed in package.json

P粉208469050
P粉208469050

reply all(2)
P粉349222772

If you look carefully at your import declaration

mistake:/!\

import { Search } from "@material-ui/icons/Search

You are importing a module named "Search", which already has a default export.
In order to use the default export you should use

Work:

import Search from "@material-ui/icons/Search

If you want to import multiple icons, you should use route /icons,
Then use all the icons you want, here's how to achieve this:

Work:

import { Search, Mail } from "@material-ui/icons

Install and run:

npm install @mui/icons-material @mui/material @emotion/styled @emotion/react
P粉451614834

The correct import is:

import SearchIcon from '@mui/icons-material/Search';

You must install it if you haven’t already

npm i @mui/icons-material

You can find all icons here: https://mui.com/material -ui/material-icons/

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!