Skip to content

Instantly share code, notes, and snippets.

@robhurring
Last active August 29, 2015 14:16
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 robhurring/683a11e5607005ea6e3e to your computer and use it in GitHub Desktop.
Save robhurring/683a11e5607005ea6e3e to your computer and use it in GitHub Desktop.
forMatt
var UserSelect = React.createClass({
_changed: function(event) {
var value = this.refs.box.getDOMNode().value;
this.props.onSelect(value);
},
render: function() {
var items = this.props.items.map(function(item) {
return (
<option value={item}>{item}</option>
)
});
return (
<select ref="box" onChange={_changed}>
{items}
</select>
)
}
})
var SomeShit = React.createClass({
getInitialState: function() {
return {
users: [1,2,3]
};
},
componentWillMount: function() {
var self = this;
getUsers().then(function(response) {
self.setState({users: response.users});
})
},
_selected: function(value) {
alert("value");
},
render: function() {
var users = this.state.users;
if(users.length == 0) {
return (<div>Loading...</div>)
} else {
return (
<UserSelect items={this.state.users} onSelect={_selected} />
)
}
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment