Adds ability to search for recipe & search for errors - #4
Open
katiedavis wants to merge 2 commits into
Open
Conversation
timestep
reviewed
Feb 28, 2018
| import React from "react"; | ||
|
|
||
| export const Search = ({ onChange, value }) => { | ||
| return <input value={value} onChange={e => onChange(e)} />; |
There was a problem hiding this comment.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
With literally no styling or tests...yet!