Skip to content

Commit

Permalink
switch to guard check to return bad case, instead of check in component
Browse files Browse the repository at this point in the history
  • Loading branch information
shapiromatron committed Sep 9, 2024
1 parent f8cf5bb commit b6c44dd
Showing 1 changed file with 17 additions and 16 deletions.
33 changes: 17 additions & 16 deletions frontend/animal/VocabBrowser/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import _ from "lodash";
import {inject, observer} from "mobx-react";
import PropTypes from "prop-types";
import React, {Component} from "react";
import Alert from "shared/components/Alert";

import EhvTable from "./EhvBrowser/Table";
import ToxRefDBTable from "./ToxRefDBBrowser/Table";
Expand All @@ -22,23 +23,23 @@ class App extends Component {
render() {
const tables = {ehv: EhvTable, toxrefdb: ToxRefDBTable},
Table = tables[this.props.store.config.vocab];

if (_.isUndefined(Table)) {
return <Alert message={"ERROR - unknown vocabulary"} />;
}
return (
<>
<div className="input-group">
<input
id="searchQuery"
className="form-control"
type="text"
value={this.state.query}
onChange={e => {
this.setState({query: e.target.value});
this.updateQuery();
}}
/>
</div>
{_.isUndefined(Table) ? <p>ERROR - unknown vocabulary</p> : <Table />}
</>
<div className="input-group">
<input
id="searchQuery"
className="form-control"
type="text"
value={this.state.query}
onChange={e => {
this.setState({query: e.target.value});
this.updateQuery();
}}
/>
<Table />
</div>
);
}
}
Expand Down

0 comments on commit b6c44dd

Please sign in to comment.