Skip to content

html-react-parser not working with full HTML when using React 19 createRootΒ #1812

Open
@Nimit012

Description

@Nimit012

Description:

I was using html-react-parser with React 18 and ReactDOM.render, and it worked fine when parsing full HTML strings. However, after upgrading to React 19 and switching to the new createRoot API, the parse method is no longer working correctly when I pass the entire HTML (including <html>, <head>, and <body> tags), not just the content inside the <body>.

Steps to Reproduce:

React 18 + ReactDOM.render + html-react-parser parsing full HTML string β€” works fine.

React 19 + createRoot + html-react-parser parsing the same full HTML string β€” does not work as expected.

Expected Behavior:

The parser should work the same way regardless of React version or rendering method, correctly parsing full HTML strings.

Actual Behavior:

Parsing full HTML with createRoot in React 19 fails or behaves unexpectedly.

Additional Info:

I have working examples on Stackblitz showing both scenarios. Here are the links:

React 18 + ReactDOM.render example: https://stackblitz.com/edit/react-ts-frs8wqq8?file=index.tsx

React 19 + createRoot example: https://stackblitz.com/edit/react-lqgcckqo?file=src%2Findex.js

Could you please check if this is a compatibility issue with React 19’s createRoot or if there is a recommended workaround?

Metadata

Metadata

Labels

wontfixThis will not be worked on

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions