Skip to content

Instantly share code, notes, and snippets.

@blabadi
Created September 9, 2018 04:33
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 blabadi/ab845d64ea23e9930b3cb01dbd4beaee to your computer and use it in GitHub Desktop.
Save blabadi/ab845d64ea23e9930b3cb01dbd4beaee to your computer and use it in GitHub Desktop.
import React, {Component} from 'react';
import SearchBox from '../components/search/SearchBox';
import {instance as foodRepo} from '../repos/FoodRepo'
class Dashboard extends Component {
state = {
searchResults: []
}
onTermChange = (term) => {
console.log(term);
const results = foodRepo.findFood(term);
this.setState({ searchResults : results.map(food => {
return {
key: food.id,
text: food.name + ", " + food.unit
}
})
});
console.log(results);
}
render() {
return (
<div className="row">
<div className="col-md-12">
<SearchBox
placeholderText="Search for food"
title="Add New Entry"
onTermChange={this.onTermChange}
results={this.state.searchResults}></SearchBox>
</div>
</div>
);
}
}
export default Dashboard;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment