79166690

Date: 2024-11-07 13:43:07
Score: 0.5
Natty:
Report link

I found an answer myself. I created the following wrapper function around the SVG component and styled this component rather than the SVG itself:

import SVG from 'react-inlinesvg';
import { ComponentProps } from 'react';

function StaticSrcSVG(src: string) {
    return Object.assign(
        (props: Omit<ComponentProps<typeof SVG>, 'src'>) => <SVG src={src} {...props} />,
        { 
            displayName: `${src}(StaticSrcSVG)`
        }
    );
}
Reasons:
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (0.5):
Posted by: Ptolemy2002