最佳答案
当呈现组件时,我会得到以下警告:
警告: 组件是
contentEditable
,包含children
现在你们有责任保证没有人 意外地修改或复制这些节点的 可能不是故意的。
这是我的组成部分:
import React, { Component } from "react";
export default class Editable extends Component {
render() {
return (
<div contentEditable={true} onBlur={this.props.handleBlur}>
{this.props.children}
</div>
);
}
}
React 想要警告我的代码有什么潜在的问题?在阅读 https://reactjs.org/docs/dom-elements.html的文档时,我不太明白。
我想象我的组件应该像托管输入字段一样工作,没有任何问题:
this.props.children
是初始值onBlur
回调更新来自 event.target.innerHTML
的道具