CodeYourFuture / CodeYourFuture/React-Module-Project

Feature Search State

未关闭
#17 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
🐂 Size Medium 📅 Week 3 🧩 Feature
主要语言
JavaScript
星标
1
派生
28
PR 合并指标
30 天内没有已合并 PR

描述

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 `` 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 `` 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

贡献指南

这个仓库没有索引到贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。