Skip to content
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

Feature Search State #19

Open
3 tasks
areebsattar opened this issue Feb 24, 2024 · 0 comments
Open
3 tasks

Feature Search State #19

areebsattar opened this issue Feb 24, 2024 · 0 comments

Comments

@areebsattar
Copy link
Owner

From React-Module-Project created by SallyMcGrath: CodeYourFuture#17

Storing the search input in a state

Instructions:

Implement the functionality to search for a customer name given the text typed into the customer name field.

In the src/Search.js file, declare a new state variable named searchInput with the corresponding setter function setSearchInput (hint: use the React function useState). The initial value of the searchInput variable can be an empty string. Add a value property to the <input> tag that is set to the new searchInput state variable.

Create a new function handleSearchInput taking an event parameter. This function should use the setSearchInput function to update the state variable searchInput with what the user typed in the input field. Finally, add a onChange prop to the <input> tag that is set to the function handleSearchInput. Use console.log() to output the value received in the handleSearchInput function.

Hint: Use event.target.value to get the input value.

Test:

  • Given a searchInput
  • When I type in the field
  • Then the value is logged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

No branches or pull requests

2 participants