简体   繁体   中英

React material-ui: How to map over all Icons?

I want to map over all @material-ui/icons in React.

I can import a single Icon like this

import IconName icons from '@material-ui/icons/IconName'

and display it

<IconName />



I want to import all available icons

import * as icons from '@material-ui/icons';

and display them all... something like

icons.map(Icon => <Icon />)



Any other way would do as well, I just don't want to store a static dictionary of all icon codes.

you have to transform names of each single icon to underscore_case and place it between Icon tag from '@material-ui/core/Icon'.

AddCircle => add_circle

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM