删除React组件内容可编辑警告

问题描述 投票:0回答:1

我创建了一个反应组件,它是弹出悬停中模型内的一个表单。但是每次我加载页面时,都会在控制台中收到以下警告,我想将其删除。

这是警告-

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
FormControl@http://localhost:3001/static/js/1.chunk.js:31598:18
WithStyles@http://localhost:3001/static/js/1.chunk.js:78328:25
TextField@http://localhost:3001/static/js/1.chunk.js:52126:22
WithStyles@http://localhost:3001/static/js/1.chunk.js:78328:25

如果我错过了任何信息或代码片段,请告诉我。

javascript reactjs console components warnings
1个回答
0
投票

当然。由于您的问题具体是如何删除警告,因此请将以下属性添加到标签中:

suppressContentEditableWarning={true}

因此,在您提供的示例中:

<div contentEditable={true} suppressContentEditableWarning={true}>...</div>

我就不给你讲为什么 React 不希望你这么做了,yadda yadda。我确信你来这里不是为了听更多的讲座。如果你想了解下面的机制,请私信我,但是,只要说:我同意你的观点。有时这是故意的(我敢打赌,如果你真的是故意这样做的,那么你很可能是一位经验丰富的开发人员,已经知道手指挥舞着“啧啧”的东西了)。

© www.soinside.com 2019 - 2024. All rights reserved.