react
react copied to clipboard
[React 19] react-test-renderer deprecation
Summary
Today our team relies on react-test-renderer to render a JSON tree which is subsequently used for search indexing. By rendering to JSON we have a structure we can use to extract semantic data like title
, meta
, description
, etc. To do something similar without react-test-renderer
we'd have to render to HTML, and then use an HTML parser to parse and extract semantic data.
I realize that this is an "off label" use of React Test Renderer but I was hoping there would be an alternative to with react-test-renderer
's deprecation.
ReactTestRenderer.create(reactElement).toJSON();
You probably get more reliable results by rendering to HTML with the method you want (server-side rendering, client-side rendering, streaming etc). That HTML can be passed to jsdom
and then you also get a more robust query syntax and validation that your meta, title etc tags are valid.
Consider rendering React components to HTML using react-dom/server
, making react-test-renderer
obsolete. Then, parse the HTML with libraries like cheerio
. Remove semantic data such as titles, metas, descriptions, etc. This change retains your ability to index semantic data while accepting depreciation.
This issue has been automatically marked as stale. If this issue is still affecting you, please leave any comment (for example, "bump"), and we'll keep it open. We are sorry that we haven't been able to prioritize it yet. If you have any new additional information, please include it with your comment!
Closing this issue after a prolonged period of inactivity. If this issue is still present in the latest release, please create a new issue with up-to-date information. Thank you!