toReactNodes
●shopify-html · /index·function
Parses a Shopify-origin HTML string and returns a React node tree suitable for direct rendering, normalizing HTML attributes and optionally replacing tags with custom React components.
Signature
function toReactNodes(html: string, opts: ToReactNodesOptions): ReactNode;Parameters
| Name | Type | Description |
|---|---|---|
html | string | |
opts | ToReactNodesOptions |
Returns
A React node wrapping the parsed content, or null when the input is blank or yields no renderable output.
Example
const nodes = toReactNodes(product.descriptionHtml, {
components: { a: LinkComponent },
});
return <div>{nodes}</div>;Related
ToReactNodesOptions toPlainText