Skip to content

Instantly share code, notes, and snippets.

@blackbing
Created February 15, 2017 01:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save blackbing/23de26bd2cc55d4bf509d8285a6e23e2 to your computer and use it in GitHub Desktop.
Save blackbing/23de26bd2cc55d4bf509d8285a6e23e2 to your computer and use it in GitHub Desktop.
react checkbox support indeterminate
import React, { PropTypes, Component } from 'react';
class Checkbox extends Component {
static propTypes = {
indeterminate: PropTypes.bool,
};
componentDidUpdate() {
if (typeof this.props.indeterminate !== 'undefined') {
this.checkbox.indeterminate = this.props.indeterminate;
}
}
render() {
const {
indeterminate,
...rest
} = this.props;
return (
<input
ref={ (ref) => { this.checkbox = ref; } }
type="checkbox"
{ ...rest }
/>
);
}
}
export default Checkbox;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment