2017-06-19 70 views
0

我正试图在无状态响应组件内实现contenteditable div。在无状态组件中反应contenteditable

我不断收到以下警告:

warning.js:36 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. 

我该如何解决这个问题?

此外,如何阅读div上的内容?

回答

0

与任何React应用程序一样,浏览器插件和扩展修改 DOM可能会导致草稿编辑器中断。

例如,语法检查器可能会修改DOM内的DOM可编辑元素,添加类似下划线和 背景的样式。由于React无法协调DOM,如果浏览器 与预期不符,编辑器状态可能无法保持与DOM的 同步。

https://github.com/facebook/draft-js/issues/53

一种已知的错误。至于读一个div什么,分配元素的ID和..

oDoc = document.getElementById("divelement"); 
sDefTxt = oDoc.innerHTML;