react-grid-layout example Unknown prop `_grid` on <div> tag

浪子不回头ぞ 提交于 2019-12-06 04:23:05

This is a change that React made to their code base around May this year. See this pull request for more information on this.

The reason you are getting this error is because you are trying to render a none HTML recognised attribute.

In HTML5 you need to define custom attributes using data-*.

To prevent the warning from showing in your case, you will have to change your render method to this.

return (
    <div key={i} data-grid={el}>
        <DashboardTestWidget widgetName={el.name} menuName={this.props.menuName}/>
        <span className="remove" style={removeStyle} onClick={this.onRemoveItem.bind(this, i)}>x</span>
    </div>
);

Note that _grid has been changed to data-grid which react will now recognise as a valid HMTL attribute.

One thing to note with React is that it will allow you to pass custom props to custom components, but when you render those components to HTML, they need to be valid HTML attributes.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!