Details relating to major changes that the release notes don't carry: those are generated from PR titles alone, so anything a reader needs beyond a one-line title lives here.
Nothing in this package's own API changed. Every entry below comes from @tanem/svg-injector moving to v12 (see its migration notes for the packaging changes, which only affect you if you also depend on it directly).
Changed
-
Test suites running under jsdom need a
TextDecoderpolyfill. svg-injector usesTextDecoderto decode base64data:image/svg+xmlURLs as UTF-8, and jsdom does not expose it, so rendering<ReactSVG src="data:image/svg+xml;base64,…" />throwsReferenceError: TextDecoder is not defined. Add it to your Jest setup file:import { TextDecoder } from 'node:util' globalThis.TextDecoder ??= TextDecoder as typeof globalThis.TextDecoder
jsdom also lacks
CSS.escape, which svg-injector uses to look up a sprite symbol. If you render ansrcwith a fragment identifier,import 'css.escape'in the same file. -
A
srcwhose.svgappears outside the URL pathname now needs a validContent-Type. svg-injector skips theContent-Typeresponse header check for URLs ending in.svg, and it used to match that against the whole URL. It now matches against the end of the pathname, sosrc="/render?file=logo.svg"served without a validContent-Typereports an error throughonErrorwhere it previously injected. Serveimage/svg+xml(ortext/plain), or move the extension into the pathname. -
The
loadingelement now enters the DOM when the samesrcis mounted a second time. svg-injector v12 defers its callbacks, soloadingrenders and is then removed, where v11 called back synchronously for a cachedsrcand React collapsed both state updates into a single render that never showed it. Nothing paints differently: a paint-level A/B measured 1 painted frame in 95 deferred mounts against 2 in 95 synchronous ones, which is React's own scheduling either way.
Added
- An
exportsmap.react-svgandreact-svg/package.jsonare the only entry points; paths intodistare no longer reachable, even though the top-levelmain,moduleandtypesfields are still set for webpack 4 and TypeScriptnode10resolution. Node ESM consumers now get the ES module build rather than falling back to CommonJS. sideEffects: false, so bundlers can drop the package entirely when nothing is imported from it.
Changed
- The minimum supported React version is now 16.8, up from 16.0. The peer dependency range is
^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0. React's support unit is the major, and fixes for the 16.x line only ever land on 16.14.x, so individual pre-16.8 minors were never separately supported. ReactSVGis a function component built on hooks, rather than a class component.defaultPropsis gone (React 19 ignores it on function components); prop defaults are unchanged and are now applied by destructuring.ReactSVGis a value only, so it can no longer be used in a type position. A class declaration doubles as a type describing its instances, which madeOmit<ReactSVG, 'src'>and similar valid; the same code now fails withTS2749: 'ReactSVG' refers to a value, but is being used as a type here. Use the exportedPropstype instead:Omit<Props, 'src'>.refnow resolves to the outermost wrapper DOM element - anHTMLDivElement,HTMLSpanElementorSVGSVGElement, depending onwrapper- instead of theReactSVGclass instance. The class instance had no documented methods, so the DOM node is the useful thing to hand back. Type the ref as the exportedWrapperTypeif you need it.- Re-injection now only happens when a prop that affects the injected SVG changes:
src,wrapper,title,desc,evalScripts,httpRequestWithCredentials,renumerateIRIElementsoruseRequestCache. Previously any prop change re-fetched and re-injected, including ones that only apply to the React wrapper (className,style, event handlers) and inlinebeforeInjection/afterInjection/onErrorfunctions, whose identity changes on every render. Those callbacks are still always invoked in their latest form; they just no longer trigger an injection by themselves. If you were relying on a wrapper prop change to force a re-injection, changesrcinstead. - Build output filenames. The CommonJS build is
dist/react-svg.cjs(wasdist/react-svg.cjs.js) and the ES module build isdist/react-svg.mjs(wasdist/react-svg.esm.js). Type declarations aredist/react-svg.d.ctsanddist/react-svg.d.mts(wasdist/index.d.tsplus one file per source module). Importingreact-svgis unaffected. - The build pipeline moved from TypeScript plus Rollup and Babel to tsdown. Output still targets ES2019.
@babel/runtimeis no longer a runtime dependency, leaving@tanem/svg-injectoras the only one. srcis now published alongsidedistso the declaration maps resolve.
Removed
- The
Statetype export. It described the internal state shape of the class component, which no longer exists. propTypesvalidation. TypeScript types are the supported contract for props. React 19 ignorespropTypesentirely, so this only changes behaviour for React 18 and earlier in development mode, where invalid props previously logged a console warning.prop-typesand@types/prop-typesare no longer dependencies.- The separate development and production CommonJS builds.
dist/react-svg.cjs.development.js,dist/react-svg.cjs.production.jsand thedist/index.jsshim that switched between them onprocess.env.NODE_ENVare replaced by a single unminified CommonJS build. WithpropTypesgone the two builds differed only by minification, which bundlers apply themselves. - UMD builds.
dist/react-svg.umd.development.jsanddist/react-svg.umd.production.jsare no longer published, and theReactSVGbrowser global is gone. React itself stopped shipping UMD builds in v19, so script-tag usage already required pinning React 18 or earlier. If you loadreact-svgvia a script tag, pinreact-svg@^17, or switch to the ES module build with an import map or a bundler.
Changed
@tanem/svg-injectorupdated to v11 (see migration notes). This drops explicit IE / legacy browser support. The library may still work in older browsers, but compatibility is no longer tested or guaranteed. If you need IE support, pin@tanem/svg-injector@^10andreact-svg@^16.
Added
onErrorprop.
Changed
afterInjectionis no longer an error-first callback.
Removed
- Dropped support for React 15.
Changed
- Restored extra wrapper element in rendered output.
Changed
- Fetch errors are no longer cached (see tanem/svg-injector#692).
Changed
- Removed extra wrapper element in rendered output.
Added
- Named type definition exports.
Changed
ReactSVGis now a named export.
Added
beforeInjectionprop.
Changed
onInjectedprop renamed toafterInjection.
Removed
svgClassNameprop has been removed. Instead, usebeforeInjectionto add the class name to the SVG DOM element.svgStyleprop has been removed. Instead, usebeforeInjectionto add the style attribute to the SVG DOM element.
Changed
@tanem/svg-injectorupdated to its latest version. The dependency was significantly refactored. There were no breaking API changes toreact-svg, but the major version was bumped to reduce the risk of unexpected breakage in consuming code.
Added
fallbackprop.
Changed
onInjectedis now an error-first callback.
Changed
pathprop renamed tosrc.
Added
- All additional non-documented props will now be spread onto the wrapper element.
Changed
callbackprop renamed toonInjected.classNameprop renamed tosvgClassName.styleprop renamed tosvgStyle.
Removed
wrapperClassNamehas been removed. Instead, passclassNamesince it will be spread onto the wrapper element.