Skip to content

Instantly share code, notes, and snippets.

@gyng
Created October 2, 2020 05:46
Show Gist options
  • Save gyng/30d8da10ed1064a0ee900d70aec85c4e to your computer and use it in GitHub Desktop.
Save gyng/30d8da10ed1064a0ee900d70aec85c4e to your computer and use it in GitHub Desktop.
SVGR TypeScript + Jest definitions
declare module "*.svg" {
import * as React from "react";
const ReactComponent: React.FunctionComponent<React.SVGProps<SVGSVGElement>>;
export { ReactComponent };
export default ReactComponent;
}
module.exports = {
...otherStuff,
moduleNameMapper: {
// .svg should have high priority
"\\.svg$": "<rootDir>/test/helpers/svgrMock.js",
}
}
export default "svg";
export const ReactComponent = "svg";
import MySvg from "mysvg.svg";
const MyComponent = () => <MySvg />;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment