Skip to content

Instantly share code, notes, and snippets.

@ochowie
Last active May 11, 2016 03:59
Show Gist options
  • Save ochowie/a09d877d7bcb50c10fbda4f4e3e642bd to your computer and use it in GitHub Desktop.
Save ochowie/a09d877d7bcb50c10fbda4f4e3e642bd to your computer and use it in GitHub Desktop.
import React from 'react';
import ReactDOM from 'react-dom';
import AutoComplete from 'material-ui/AutoComplete';
import getMuiTheme from 'material-ui/styles/getMuiTheme';
import MuiThemeProvider from 'material-ui/styles/MuiThemeProvider';
class AutoCompleteTest extends React.Component {
constructor(props) {
super(props);
this.state = {
dataSource: [],
searchText: ''
};
}
handleUpdateInput(value) {
this.setState({
dataSource: [
value,
value + value,
value + value + value,
],
});
};
handleNewRequest(value) {
this.setState({
searchText: ''
});
}
render() {
return (
<div>
<AutoComplete
hintText="Type anything"
dataSource={this.state.dataSource}
onUpdateInput={this.handleUpdateInput.bind(this)}
onNewRequest={this.handleNewRequest.bind(this)}
searchText={this.state.searchText}
/>
</div>
);
}
}
const muiTheme = getMuiTheme();
ReactDOM.render(
<MuiThemeProvider muiTheme={muiTheme}>
<AutoCompleteTest />
</MuiThemeProvider>,
document.getElementById('main')
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment