Warning: A component is `contentEditable` and contains `children` managed by React
See original GitHub issueThe 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:
- Created 8 years ago
- Comments:11 (1 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I ended up adding this code to my project as a temporary solution:
With the suppressContentEditableWarning prop you can solve this issue