- README: project logo in the header.
- README: new header, features list, table of contents, install command for pnpm, and a note that the browser entries need a DOM.
exportsnames the type file for each entry and module format, so TypeScript picks.d.tsforimportand.d.ctsforrequirewithout guessing.- The package ships
CHANGELOG.md, andauthornames the maintainer.
The default entry now sanitizes, and React Native gets its own entry.
- React 18 or newer. The
reactpeer range moves from>=16.8.0to>=18.0.0. The native entry also needsreact-native >=0.71. parsesanitizes by default.parsefromreact-html5-parserruns DOMPurify over the parsed tree. Output that used to render can now be stripped:<script>, event handlers (onclick),javascript:URLs,<iframe>,<embed>and<object>;<style>and<title>, which act on the whole page;- the
formandformactionattributes; styleattributes that setposition: fixed;- attributes outside DOMPurify's allowlist, such as
contenteditableandfetchpriority; - unknown and custom elements, unless the tag is mapped in
components(their content is kept).
- Bigger default entry. It grows from about 1.4 kB to about 15 kB min + gzip, because DOMPurify is bundled. Import from
react-html5-parser/coreto keep the old size and behaviour. sanitizeno longer replaces the sanitizer on the default entry. DOMPurify runs after yoursanitizefunction. To use only your own sanitizer, import from/core.componentsentries render as React components. They were called as plain functions before. Hooks inside them now work, but an inline arrow function remounts its subtree on every render, and a component that returnsundefinedthrows on React 18. Define components outside render and returnnullfor nothing.mapElementreceives the component element for a tag mapped incomponents, not the element the component returned.MapComponentFnprops no longer includekey. The type is nowComponentProps(PropsWithChildren<Attributes>).
react-html5-parser/core: the unsanitized parser, about 3 kB.react-html5-parser/native: renders HTML to React NativeView,TextandImage, withcomponents,tagStyles,textStyle,onLinkPressandmapElementoptions. Links open only forhttp,https,mailtoandtel; images load only fromhttp,httpsand raster data URIs.purifyoption on the default entry: a DOMPurify config merged over the built-in one.- CommonJS builds next to ESM for every entry.
- SVG attributes (
viewBox,stroke-width,xlink:hrefand the rest) map to their React names by default. - Form fields render uncontrolled (
defaultValue,defaultChecked), so React no longer warns about avaluewithoutonChange. - On React 19,
<script async>is rendered inert instead of hoisted and run, and<html>/<body>no longer bind to the page's own. - Custom elements keep their attribute names as written.
attrsMapapplies to every element, including mapped components.
See Upgrading from 0.x.