npm / react-highlight-words
react-highlight-words
What changed in react-highlight-words 0.21 to 1, from its official release notes, upgrade guides and advisories. Sources checked 2026-10-18.
11 breaking4 new APIs and options1 performance2 behavior and defaults1 tooling8 fixes and other
See which of these apply to your code, ranked, in your agent:
npx @unstale/cli initreact-highlight-words 120 changes
Breaking changes 8
String search words are matched literally by default because autoEscape now defaults to true.
The exported Chunk type now requires searchIndex, the index of the matching search word.
highlight-words-core 2.0 is published as ES2020, so environments and bundlers that cannot parse that syntax need to transpile it.
Only the package root can be imported; deep imports are no longer available.
Custom findChunks functions must return searchIndex in each chunk and now receive every option with its default applied.
React 16.3 or newer is required; React 0.14, 15, and 16.0–16.2 are no longer supported.
A ref is forwarded to the outer wrapper span; this requires React 16.3 or newer.
When sanitize changes text, it is applied to each character separately, so context-dependent sanitizers produce different results.
New APIs and options 2
FoundChunk is exported as an alias of Chunk, matching its name in highlight-words-core.
Custom highlightTag components receive searchIndex, identifying the matching search word.
Behavior and default changes 2
When autoEscape is false, invalid regular-expression strings are matched literally instead of throwing an error.
Search words can include RegExp objects, which are used as-is with their own flags.
Fixes and other changes 8
Inactive matches no longer have a trailing space in their class name, and elements without a class name no longer render an empty class attribute.
CommonJS consumers now get correct component and namespace types, including with node16 module resolution.
For object values, unmatched text uses the class of the search word that matched instead of an undefined class name.
Object values no longer give matches such as constructor or toString a class name from inherited properties.
Matches line up with the original text when sanitize changes its length.
searchWords can be a readonly array, allowing values such as arrays declared with as const.
Surrogate pairs such as emoji are no longer split between highlighted and unhighlighted text.
A missing or non-string textToHighlight from untyped callers no longer throws an error.
react-highlight-words 0.217 changes
Breaking changes 3
Removes the UMD build.
Stops bundling highlight-words-core and installs it as a regular dependency at ^1.2.0.
The package targets ES2018+ syntax instead of ES5; environments unable to parse it need to transpile the package.
New APIs and options 2
Adds TypeScript definitions, including HighlighterProps, HighlightTagProps, UnhighlightTagProps, Chunk and FindChunksOptions.
Adds an ES module build and exposes it through the package's module field.
Performance 1
When caseSensitive is false, lowercases object keys once per render instead of once per match.
Tooling 1
Moves the CommonJS entry point from dist/main.js; require("react-highlight-words") still returns the component directly.