Skip to content

Commit

Permalink
fix(withVerb): unnoticeable error when typing a verb
Browse files Browse the repository at this point in the history
  • Loading branch information
ThamosIO committed Apr 22, 2020
1 parent d515204 commit 7e77113
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
Binary file modified front/assets/sample.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 4 additions & 2 deletions front/components/HOC/withVerb.jsx
Expand Up @@ -13,6 +13,8 @@ function withVerb(WrappedComponent, title) {
const { verbs } = API;

const onVerbChange = async (e, { value }) => {
if (!value) return;

const found = verbs.find((v) => v.verb === value);

const response = await fetch(`${API_URL}/verbs/${found._id}`);
Expand All @@ -21,10 +23,10 @@ function withVerb(WrappedComponent, title) {
setVerb(res);
};

const randomize = async (e, { value }) => {
const randomize = async () => {
const random = verbs[Math.trunc(Math.random() * verbs.length)];

onVerbChange(e, { value: random.verb });
onVerbChange(null, { value: random.verb });
};

const tenses = verb?.tenses.map(({ tense }) => ({
Expand Down

0 comments on commit 7e77113

Please sign in to comment.