Function component for entry

This commit is contained in:
greg 2019-01-26 01:34:35 -08:00
parent d77e09052a
commit e88c8b954e
1 changed files with 16 additions and 9 deletions

25
App.jsx
View File

@ -20,6 +20,19 @@ function testHandler(json) {
console.log(json);
}
function Entry(props) {
const entry = props.entry;
return (
<div className="searchResult" key={ entry.id }>
<b>{ entry.sai }</b> - { entry.eng }
<br />
<span className="synclass">{ entry.syn_category }</span>
<br />
Type: { entry.morph_type }
</div>
);
}
class Results extends Component {
constructor(props) {
super(props);
@ -31,15 +44,9 @@ class Results extends Component {
<div className="searchResultHeader">
Searched for <b>{ this.props.searchTerm }</b> search type: { this.props.searchType }
</div>);
const entries = this.props.searchResults.map((entry, idx) => {
return (<div className="searchResult" key={ entry.id }>
<b>{ entry.sai }</b> - { entry.eng }
<br />
<span className="synclass">{ entry.syn_category }</span>
<br />
Type: { entry.morph_type }
</div>);
});
const entries = this.props.searchResults.map(
(entry, idx) => <Entry entry={ entry } key= { entry.id } />
);
return [header].concat(entries);
}