You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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();
The text was updated successfully, but these errors were encountered:
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.
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 withoutreact-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.The text was updated successfully, but these errors were encountered: