Skip to content

Suppressing "A component is contentEditable" warning #4662

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

Closed
joshma opened this issue Aug 19, 2015 · 1 comment
Closed

Suppressing "A component is contentEditable" warning #4662

joshma opened this issue Aug 19, 2015 · 1 comment

Comments

@joshma
Copy link
Contributor

joshma commented Aug 19, 2015

We're writing a WYSIWYG editor in React, and in order to place a cursor inside the rich document we use contentEditable. Understandably, React doesn't fare well with contentEditable - to get around the framework's confusion once contentEditable children are modified, we force re-renders with new keys and do other work to restore the selection. In practice, we have this working pretty well.

With 0.12, we're getting the new warning:

A component is contentEditable and contains children managed by React. It is now your responsibility to guarantee that none of these nodes are unexpectedly modified or duplicated. This is probably not intentional.

In our case, we do guarantee that nodes are unexpectedly modified or duplicated, and it is intentional. Is there any way to suppress that warning? Unlike the Factory warning, this warning appears each time the component is instantiated (I think) - at the very least, it slowly fills up our consoles.

(We've considered an alternative of not using children on the contentEditable, and on component update we set the innerHTML outside of React - this would likely sidestep the warning, but not get us much else.)

@joshma
Copy link
Contributor Author

joshma commented Aug 19, 2015

Ah, a team member pointed out React warns when we use children but NOT dangerouslySetInnerHTML, and it turns out most of our calls use dangerouslySetInnerHTML - only a few places use children, and those places are all text nodes. In this case, we'll likely switch those latter cases to using dangerouslySetInnerHTML as well, so I'll close this task for now.

Obviously, welcome to re-open if you think suppressing the warning is something worth considering.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant