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

@nordcom/commerce-shopify-html
function toReactNodes(html: string, opts: ToReactNodesOptions): ReactNode;

Parameters

NameTypeDescription
htmlstring
optsToReactNodesOptions

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>;

ToReactNodesOptions toPlainText

Metadata@nordcom/commerce-shopify-html@0.0.0Open in GitHub ↗

On this page