question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

A way to disable contenteditable warnings

See original GitHub issue

https://github.com/facebook/react/blob/0e8db6ba424564833866a3044e62f4034ec98faa/src/renderers/dom/shared/ReactDOMComponent.js#L178-L184

React warns:

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

I am writing a rich text editor using React, and have written it to ensure that the nodes are not modified by the browser by capturing all input events, performing the modifications on my internal document format, and re-rendering using React. However, on each render, React still warns me about this.

I would be awesome to be able to disable this warning somehow, such as with a specific value to the contentEditable prop, another name or something. I’m not sure the best approach to take here, so I thought I’d create an issue for discussion around this.

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Reactions:11
  • Comments:15 (8 by maintainers)

github_iconTop GitHub Comments

13reactions
mjgilcommented, Feb 2, 2016

+1

10reactions
jimfbcommented, Feb 2, 2016

You can capture input events without content editable (http://jsfiddle.net/vm9gjhs3/) and can simulate the cursor behavior yourself (which you basically need to do anyway in order to implement a good editor, as per https://medium.com/medium-eng/why-contenteditable-is-terrible-122d8a40e480#6497). The browsers all have different behaviors with regards to how cursor position works. If you want a truly nice editor, you will end up using almost nothing from contentEditable. But I get it, you’re trying to reuse the browser’s functionality under the (very optimistic) assumption that contentEditable gets you most of the way there.

With regards to your hack: A better stopgap solution (hack) would probably be to set contentEditable imperatively (as demonstrated in my fiddle: http://jsfiddle.net/4q2p6ug8/). That way, React doesn’t even know you’ve set it, and you can share your component without overwriting other people’s console.error method.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why does React warn against an contentEditable component ...
I get the following warning when rendering my component: Warning: A component is contentEditable and contains children managed by React.
Read more >
How to disable react warnings : r/reactjs - Reddit
How to disable react warnings. In order to have multiple contenteditable sibling components that behave nicely (eg: using the arrow keys to move...
Read more >
ContentEditableDisabled - W3C on GitHub
This specification defines an API that indicates which editing-related commands are applicable to contenteditable regions of a document.
Read more >
How To Remove Contenteditable Border - W3Schools
Tip: Go to our HTML contenteditable Attribute Reference to learn more about the global contenteditable attribute. Tip: Go to our CSS [attribute] Selector...
Read more >
The Road to HTML 5: contentEditable - The WHATWG Blog
The feature of the day is contentEditable , by which I mean client-side in-browser "rich text" editing. All major browsers support this now,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found