Created
June 23, 2015 23:23
-
-
Save jonjaques/5a1673e2afd0b8736ebe to your computer and use it in GitHub Desktop.
React Bootstrap ButtonGroup with Radio/Checkbox behavior
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
/* | |
works like a standard controlled input... | |
DOES NOT work without it, so you must either supply | |
a value + onChange or a valueLink | |
*/ | |
import ButtonGroupSelect from './buttonselect' | |
export default React.createClass({ | |
mixins: [ | |
React.addons.LinkedStateMixin | |
], | |
handleRadioSelect(values) { | |
console.log(values) // { foo: true, bar: false, baz: false } | |
this.setState({ radio1: values }) | |
}, | |
render() { | |
return <div> | |
<ButtonGroupSelect type="radio" value={this.state.radio1} onChange={this.handleRadioSelect}> | |
<Button eventKey="foo">Foo</Button> | |
<Button eventKey="bar">Bar</Button> | |
<Button eventKey="baz">Baz</Button> | |
</ButtonGroupSelect> | |
<ButtonGroupSelect type="checkbox" valueLink={this.linkState('radio2')}> | |
<Button eventKey="test1">Test 1</Button> | |
<Button eventKey="test2">Test 2</Button> | |
</ButtonGroupSelect> | |
</div> | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment