-
Notifications
You must be signed in to change notification settings - Fork 47.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
hydrating a component with dangerouslySetInnerHTML
and toString
causes a warning, and the component to not render
#11789
Comments
I would really like to take this! I'm going to take a look more deeply in a few hours/tomorrow. If anyone care to point me to anything, that would be great. Should be my first contribution! |
@nubunto Good luck! |
@magicmark does your last commit fix the issue? (since the tests seem to pass now) And if so can we make a PR for this? |
@robgietema the PR is here #11792 |
@gaearon @magicmark do we have any update on the issue and PR? |
Reviewed the PR: #11792 (review) |
@magicmark @gaearon I found a way to work around this issue and avoid using dangerouslySetInnerHtml using an HTML parser package such as react-html-parser, it basically parses the HTML and outputs react elements so you are not using dangerouslySetInnerHtml at all! |
Do you want to request a feature or report a bug?
bug
What is the current behavior?
When hydrating a pre-rendered component that uses
dangerouslySetInnerHTML
, + an object with atoString
method, we get a warning such as:The component will also appear blank.
This is noteworthy since:
render
appears to be correct, meaning:render
on the client, without SSR is correctIf the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem via https://jsfiddle.net or similar (template for React 16: https://jsfiddle.net/Luktwrdm/, template for React 15: https://jsfiddle.net/hmbg7e9w/).
https://codesandbox.io/s/vqkq34o965
(Code, for posterity:)
What is the expected behavior?
The component is not blank, and no error is outputted in the console
Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React?
render
method)The text was updated successfully, but these errors were encountered: