From 0d5e2c90a26179b5712ed78ac4c5506cf5c62cea Mon Sep 17 00:00:00 2001 From: Greg Shuflin Date: Sun, 12 Sep 2021 01:07:30 -0700 Subject: [PATCH] App.jsx improvements --- src/App.jsx | 46 +++++++++++++++++++--------------------------- 1 file changed, 19 insertions(+), 27 deletions(-) diff --git a/src/App.jsx b/src/App.jsx index 51bba26..4a9fe4f 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -32,20 +32,19 @@ function renderConlangName(name) { } } -function Entry(props) { +const Entry = (props) => { const {conlang} = props; if (conlang === 'saimiar') { return ; } return
Unknown entry type for { conlang }
; -} +}; -function SaiEntry(props) { +const SaiEntry = (props) => { const {entry} = props; const synCategory = entry.syn_category; const isNominal = synCategory === 'nominal'; - console.log(isNominal); return (
{ entry.sai } - { entry.eng } @@ -58,7 +57,7 @@ function SaiEntry(props) {
); -} +}; function formatMorphology(entry) { const decl = declineSaimiar(entry); @@ -77,36 +76,29 @@ function formatMorphology(entry) { ); } -class Results extends Component { - constructor(props) { - super(props); - this.content = this.content.bind(this); - } - - content() { - const {conlang} = this.props; - const num = this.props.searchResults.length; +const Results = (props) => { + const content = () => { + const {conlang} = props; + const num = props.searchResults.length; const renderedName = renderConlangName(conlang); - const searchType = (this.props.direction === 'toConlang') ? `English -> ${renderedName}` : `${renderedName} -> English`; + const searchType = (props.direction === 'toConlang') ? `English -> ${renderedName}` : `${renderedName} -> English`; const header = (
- Searched for { this.props.searchTerm }, { searchType }, found { num } result(s) + Searched for { props.searchTerm }, { searchType }, found { num } result(s)
); - const entries = this.props.searchResults.map( + const entries = props.searchResults.map( (entry, _idx) => , ); return [header].concat(entries); - } + }; - render() { - const results = this.props.searchResults; - return ( -
- { results ? this.content() : 'No search' } -
- ); - } -} + const results = props.searchResults; + return ( +
+ { results ? content() : 'No search' } +
+ ); +}; class App extends Component { constructor(props) {