微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

javascript – 在无状态组件中做出反应

我试图在无状态反应组件中实现一个可信的div.

我一直收到以下警告:

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的内容

解决方法

As with any React application,browser plugins and extensions that modify
the DOM can cause Draft editors to break.

Grammar checkers,for instance,may modify the DOM within
contentEditable elements,adding styles like underlines and
backgrounds. Since React cannot reconcile the DOM if the browser does
not match its expectations,the editor state may fail to remain in
sync with the DOM.

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

一个已知的错误.至于在div中读取什么,请为元素分配一个id和..

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

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐