Skip to content

Commit

Permalink
Search funtionality added on key press "Enter"
Browse files Browse the repository at this point in the history
  • Loading branch information
aashay28 committed Apr 25, 2023
1 parent 9dbfca4 commit 7f3cb7b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
1 change: 0 additions & 1 deletion src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import datas from "./data/Profile.json";

function App() {
const [profiles, setProfiles] = useState([]);
console.log(profiles);

const handleSearch = (searchValue) => {
const lowercaseSearch = searchValue.toLowerCase();
Expand Down
7 changes: 6 additions & 1 deletion src/components/Search/Search.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,19 @@ function Search({ onSearch }) {
const handleSearch = () => {
onSearch(searchValue);
};

const handleSearchOnEnter = (e) => {
if (e.keyCode === 13) {
handleSearch();
}
};
return (
<div className="search-bar">
<input
type="text"
onChange={handleInputChange}
value={searchValue}
placeholder="Find users with specific skills"
onKeyDown={handleSearchOnEnter}
/>
<FontAwesomeIcon
onClick={handleSearch}
Expand Down

0 comments on commit 7f3cb7b

Please sign in to comment.