index.tsx 335 B

123456789101112131415161718
  1. import PropTypes from 'prop-types';
  2. import IconMap from './IconMap';
  3. /**
  4. * 图标兼容组件
  5. * @type {any}
  6. */
  7. function Icon({ type, ...otherProps }: any) {
  8. const ICON = IconMap[type];
  9. if (ICON) return <ICON {...otherProps} />;
  10. return null;
  11. }
  12. Icon.propTypes = {
  13. type: PropTypes.string.isRequired,
  14. };
  15. export default Icon;