All files / src/components/icons DynamicIcon.tsx

100% Statements 4/4
50% Branches 1/2
100% Functions 1/1
100% Lines 4/4

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16        67x   15x 15x 15x              
import React, { ReactElement } from 'react';
import { RightSquareOutlined } from '@ant-design/icons';
 
// eslint-disable-next-line  @typescript-eslint/no-explicit-any
const DynamicIcon = ({ type, ...rest }: { type: string; rest?: any }): ReactElement => {
  // eslint-disable-next-line @typescript-eslint/no-var-requires
  const icons = require(`@ant-design/icons`);
  const Component = icons[type];
  return (Component == null) ?
    // eslint-disable-next-line @typescript-eslint/ban-ts-comment
    // @ts-ignore
    <RightSquareOutlined {...rest} /> : <Component {...rest} />;
};
 
export default DynamicIcon;