尝试从Material UI使用工具提示会导致以下错误:
Warning: The final argument passed to useEffect changed size between renders. The order and size of this array must remain constant.
Previous: []
Incoming: [, function () {
if (isControlled !== (controlled !== undefined)) {
console.error(["Material-UI: a component is changing the ".concat(isControlled ? '' : 'un', "controlled ").concat(state, " state of ").concat(name, " to be ").concat(isControlled ? 'un' : '', "controlled."), 'Elements should not switch from uncontrolled to controlled (or vice versa).', "Decide between using a controlled or uncontrolled ".concat(name, " ") + 'element for the lifetime of the component.', "The nature of the state is determined during the first render, it's considered controlled if the value is not `undefined`.";
}
}, 0]
工具提示被包裹在一个加载了"react SVG loader"的SVG图标上:
<Tooltip title={'Filters'}>
<div>
<Filter className={classes.topIcon}
onClick={()=> {console.log('Hello');}}/>
</div>
</Tooltip>
我已经将它包装在div中,正如本线程中所建议的那样:Material UI工具提示没有';t在自定义组件上显示,尽管将道具扩散到该组件
虽然这使工具提示起作用,但每当鼠标悬停在图标上并扰乱控制台时,它仍然会返回错误。
知道怎么摆脱它吗?
谢谢!
编辑:
即使使用"材质ui/icons"中的图标,也会出现相同的错误。
第2版:
作为最后的手段,尝试在Tooltip中围绕一个普通的div。相同的结果-悬停在上方时出现红色大警告
<FormGroup className={classes.percRoot}>
<Tooltip title={'lol'}>
<div>hello</div>
</Tooltip>
</FormGroup>
根据:https://www.npmjs.com/package/react-hot-loader
或在主文件中导入"react hot-loader"(在react之前(
奇怪的是,在这之前,所有带有热重新加载程序的东西都能完美工作。只有在使用工具提示时,问题才浮出水面。