Skip to content
Create a gist now

Instantly share code, notes, and snippets.

anonymous /app.js
Created Jun 25, 2014

How to use Twitter Typeahead with react
var states = ['Alabama', 'Alaska', 'Arizona', 'Arkansas', 'California',
'Colorado', 'Connecticut', 'Delaware', 'Florida', 'Georgia', 'Hawaii',
'Idaho', 'Illinois', 'Indiana', 'Iowa', 'Kansas', 'Kentucky', 'Louisiana',
'Maine', 'Maryland', 'Massachusetts', 'Michigan', 'Minnesota',
'Mississippi', 'Missouri', 'Montana', 'Nebraska', 'Nevada', 'New Hampshire',
'New Jersey', 'New Mexico', 'New York', 'North Carolina', 'North Dakota',
'Ohio', 'Oklahoma', 'Oregon', 'Pennsylvania', 'Rhode Island',
'South Carolina', 'South Dakota', 'Tennessee', 'Texas', 'Utah', 'Vermont',
'Virginia', 'Washington', 'West Virginia', 'Wisconsin', 'Wyoming'
var TypeaheadInput = React.createClass({
componentDidMount: function () {
{ hint: true, highlight: true, minLength: 1 },
{ name: 'states', displayKey: 'value', source: substringMatcher(this.props.options)}
render: function() {
return ( <input type="text" ref="input" /> );
var ExampleApplication = React.createClass({
render: function() {
var bls = function () { console.log("bla"); }
return (
<TypeaheadInput onAutocompleted={bls} options={states} />
React.renderComponent( <ExampleApplication />, document.getElementById('container'));
<!DOCTYPE html>
<meta http-equiv='Content-type' content='text/html; charset=utf-8'>
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="jquery-2.1.1.min.js"></script>
<script src="typeahead.jquery.min.js"></script>
<div id="container">
<script src="react-with-addons.min.js"></script>
<script src="JSXTransformer.js"></script>
<script type="text/jsx" src="app.js"></script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.