forked from reactplay/react-play
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Input.jsx
26 lines (21 loc) · 831 Bytes
/
Input.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import React, { useState } from 'react';
import { useResultContext } from '../context/ResultContextProvider';
const Input = () => {
const { getRepos, getUser } = useResultContext();
const [username, setUsername] = useState('');
const handleSubmit = (e) => {
e.preventDefault();
getUser(username);
getRepos(username);
setUsername('');
}
return (
<form className='nirban-github-profile-form' onSubmit={handleSubmit} >
<input tabIndex={0} autoFocus value={username} required placeholder="Search Username" onChange={(e) => setUsername(e.target.value)} className="nirban-github-profile-search" />
<button type="submit" className="nirban-github-profile-btn">
Search
</button>
</form>
)
}
export default Input