Skip to content

Instantly share code, notes, and snippets.

@robhurring robhurring/noidea.js
Last active Aug 29, 2015

Embed
What would you like to do?
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
You can’t perform that action at this time.