• Version 16.1.34
  • Published
  • 269 kB
  • 4 dependencies
  • MIT license


npm i react-svg
yarn add react-svg
pnpm add react-svg


A React component that injects SVG into the DOM.



class ReactSVG

class ReactSVG extends React.Component<Props, State> {}

    property defaultProps

    static defaultProps: {
    afterInjection: () => undefined;
    beforeInjection: () => undefined;
    desc: string;
    evalScripts: string;
    fallback: null;
    httpRequestWithCredentials: boolean;
    loading: null;
    onError: () => undefined;
    renumerateIRIElements: boolean;
    title: string;
    useRequestCache: boolean;
    wrapper: string;

      property initialState

      initialState: { hasError: boolean; isLoading: boolean };

        property nonReactWrapper

        nonReactWrapper?: WrapperType;

          property propTypes

          static propTypes: {
          afterInjection: PropTypes.Requireable<(...args: any[]) => any>;
          beforeInjection: PropTypes.Requireable<(...args: any[]) => any>;
          desc: PropTypes.Requireable<string>;
          evalScripts: PropTypes.Requireable<string>;
          fallback: PropTypes.Requireable<string | object>;
          httpRequestWithCredentials: PropTypes.Requireable<boolean>;
          loading: PropTypes.Requireable<string | object>;
          onError: PropTypes.Requireable<(...args: any[]) => any>;
          renumerateIRIElements: PropTypes.Requireable<boolean>;
          src: PropTypes.Validator<string>;
          title: PropTypes.Requireable<string>;
          useRequestCache: PropTypes.Requireable<boolean>;
          wrapper: PropTypes.Requireable<string>;

            property reactWrapper

            reactWrapper?: WrapperType;

              property refCallback

              refCallback: (reactWrapper: WrapperType | null) => void;

                property state

                state: { hasError: boolean; isLoading: boolean };

                  method componentDidMount

                  componentDidMount: () => void;

                    method componentDidUpdate

                    componentDidUpdate: (prevProps: Props) => void;

                      method componentWillUnmount

                      componentWillUnmount: () => void;

                        method removeSVG

                        removeSVG: () => void;

                          method render

                          render: () => React.JSX.Element;

                            method renderSVG

                            renderSVG: () => void;


                              interface State

                              interface State {}

                                property hasError

                                hasError: boolean;

                                  property isLoading

                                  isLoading: boolean;

                                    Type Aliases

                                    type Props

                                    type Props = BaseProps &
                                    React.DetailedHTMLProps<React.HTMLAttributes<HTMLWrapperType>, HTMLWrapperType> &

                                      type WrapperType

                                      type WrapperType = HTMLWrapperType | SVGWrapperType;

                                        Package Files (3)

                                        Dependencies (4)

                                        Dev Dependencies (42)

                                        Peer Dependencies (2)


                                        To add a badge like this badgeto your package's README, use the codes available below.

                                        You may also use to create a custom badge linking to

                                        • Markdown
                                        • HTML
                                          <a href=""><img src="" alt=""></a>