Javascript 带有React的未知属性,如何创建新的html属性
我正在尝试为我的收音机和复选框的输入元素创建一个Javascript 带有React的未知属性,如何创建新的html属性,javascript,reactjs,react-proptypes,Javascript,Reactjs,React Proptypes,我正在尝试为我的收音机和复选框的输入元素创建一个:不确定的属性 react引发了以下错误: Unknown prop `indeterminate` on <input> tag. Remove this prop from the element 标签上的未知属性“不确定”。从元件上拆下此支柱 是否可以创建新的道具或道具是否完全锁定?只需将输入包装到另一个可以接受不确定的道具的组件中: const IndeterminateInput = React.createClass({
:不确定的属性
react引发了以下错误:
Unknown prop `indeterminate` on <input> tag. Remove this prop from the element
标签上的未知属性“不确定”。从元件上拆下此支柱
是否可以创建新的道具或道具是否完全锁定?只需将输入包装到另一个可以接受不确定的道具的组件中:
const IndeterminateInput = React.createClass({
render() {
// Create props clone
const cleanProps = Object.assign({}, this.props);
delete cleanProps['indeterminate'];
return <input ref="input" {...cleanProps}/>
},
updateInput: function () {
this.refs.input.indeterminate = Boolean(this.props.indeterminate);
},
componentDidMount() {
// Initial render
this.updateInput();
},
componentDidUpdate() {
// Props change
this.updateInput();
}
});
<IndeterminateInput type="checkbox" indeterminate />
<!-- This does not work! -->
<input type="checkbox" indeterminate>