Skip to content

Adds ability to search for recipe & search for errors #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Adds ability to search for recipe & search for errors #4

wants to merge 2 commits into from

Conversation

katiedavis
Copy link

With literally no styling or tests...yet!

Copy link

@timestep timestep left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome stuff!

import React from "react";

export const Search = ({ onChange, value }) => {
return <input value={value} onChange={e => onChange(e)} />;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Be careful here. When binding an input like this, anyone can pass any function here. Like an API call 😉. What happens is that when a user types, they can keep typing, and each type will fire an independent API call. This means for hello we have 5 API requests and they all return at different times because APIs take their own time to return.

One way to fix this problem is to use a function that keeps track, or holds on to the call for a certain amount of time, until either, the timer runs out, or the function is called again. This is traditionally called a debounce function. Its pretty normal to bind one to an input.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants