Created
February 15, 2017 01:42
-
-
Save blackbing/23de26bd2cc55d4bf509d8285a6e23e2 to your computer and use it in GitHub Desktop.
react checkbox support indeterminate
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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