Last active
May 11, 2016 03:59
-
-
Save ochowie/a09d877d7bcb50c10fbda4f4e3e642bd to your computer and use it in GitHub Desktop.
This file contains 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 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