How can I dynamically load an icon using its snake_case name (React, material-ui)
问题 Normally I'd use material-ui icons by importing them directly per the material-ui instructions. But I have a text tag, which is the actual icon name (like calendar_view_day ) and need to get and render an icon component from it dynamically. How can I something like: render() { return ( <Icon name="calendar_view_day" color="primary" /> ) } Instead of: render() { return ( <CalendarViewDay color="primary" /> // Imported by name ) } 回答1: OK, so I massively overthought this. Correct answer Turns