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.

Warning: A component is `contentEditable` and contains `children` managed by React

See original GitHub issue

The following is an example editor component

` import React from ‘react’; import {Editor, EditorState} from ‘draft-js’;

export default class MyEditor extends React.Component {

constructor(props) {
    super(props);

    this.state = {
        editorState: EditorState.createEmpty()
    };
}

onChange = (editorState) => {
    this.setState({editorState});
}

render() {
    const {editorState} = this.state;
    return <Editor editorState={editorState} onChange={this.onChange} />;
}

} `

And in my parent component

import MyEditor from './MyEditor'

… // in the render() method ` render() { let error = this.getError();

    return (
        <form className="post__form">
            {error}
            <div className="form-group">
                <label htmlFor="title">Title</label>
                <input type="text" ref="title" className="form-control" id="title" placeholder="Title" />
            </div>
            <div className="form-group">
                <label htmlFor="description">Description</label>

                <MyEditor />

            </div>
            <button type="submit" onClick={this.onClickHandler.bind(this)} className="btn btn-default">Submit</button>
        </form>
    );
}

`

And I see this warning

Warning: 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.

Issue Analytics

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

github_iconTop GitHub Comments

39reactions
davismlcommented, Feb 24, 2016

I ended up adding this code to my project as a temporary solution:

console.error = (function() {
    var error = console.error

    return function(exception) {
        if ((exception + '').indexOf('Warning: A component is `contentEditable`') != 0) {
            error.apply(console, arguments)
        }
    }
})()
20reactions
RTerancommented, Apr 10, 2018

With the suppressContentEditableWarning prop you can solve this issue

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why does React warn against an contentEditable component ...
Warning: A component is contentEditable and contains children managed by React. It is now your responsibility to guarantee that none of those ...
Read more >
A component is `contentEditable` and contains ... - GitHub
When integrating draft-js into an existing project I get Warning: A component is contentEditable and contains children managed by React.
Read more >
Why does React warn against an contentEditable component ...
React is warning you that you have children within that element that are managed by React. React only works from the top down....
Read more >
Create Editable HTML in React - JavaScript in Plain English
When you add contentEditable=true to a component you see a warning from React: Warning: A component is `contentEditable` and contains ...
Read more >
Why does React warn against an contentEditable component ...
React is warning you that you have children within that element that are managed by React. React only works from the top down....
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