Open fuweichin opened 4 years ago
For the second solution, icon groups should be cached, so export and use getIconGroups
instead of createIconGroups
.
let iconGroups=null;
function getIconGroups() {
if (iconGroups===null) {
iconGroups=createIconGroups();
}
return iconGroups;
}
export { getIconGroups };
import { getIconGroups } from '@ant-design/icons';
const {
outlined: Icon, // default to outlined
filled: IconFilled,
} = getIconGroups();
Current example usage
This is a basic usage of React icon components, see official documentation
The naming issue
XxxOutlined
icons are ideographically outlined. Isn't it self-contradictory?One possible solution
Dummy usage
Reference implementation
Grouping icon components by suffixes
Outlined
Filled
andTwoTone
Another possible solution
If the implementation above slows down module initialization, then just provide a method to generate groups as needed
Reference implementation
Dummy usage