Created
September 9, 2018 04:33
-
-
Save blabadi/ab845d64ea23e9930b3cb01dbd4beaee 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, {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