React hook that computes a diff between HTML source and plain text.
The result is memoised and only recomputes when sourceHtml, targetText, or options change. See diffText for details on the return value.
sourceHtml
targetText
options
HTML string whose visible text is compared.
Plain text to compare against.
Optional
Optional highlight configuration.
A DiffTextResult with highlighted HTML, extracted text, and segments.
import { useDiffText } from "text-visual-diff/react";function DiffView({ html, text }) { const result = useDiffText(html, text); return <div dangerouslySetInnerHTML={{ __html: result.highlightedSource }} />;} Copy
import { useDiffText } from "text-visual-diff/react";function DiffView({ html, text }) { const result = useDiffText(html, text); return <div dangerouslySetInnerHTML={{ __html: result.highlightedSource }} />;}
React hook that computes a diff between HTML source and plain text.
The result is memoised and only recomputes when
sourceHtml,targetText, oroptionschange. See diffText for details on the return value.