Skip to content

Instantly share code, notes, and snippets.

@Ralexs0096
Created November 3, 2022 04:18
Show Gist options
  • Save Ralexs0096/45e8cbec2f58c09b0592c0f67fe453e4 to your computer and use it in GitHub Desktop.
Save Ralexs0096/45e8cbec2f58c09b0592c0f67fe453e4 to your computer and use it in GitHub Desktop.
import { useState } from 'react';
const App = () => {
const [data, setData] = useState({
username: '',
password: '',
});
const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {
setData({
...data,
[event.target.name]: event.target.value,
});
};
const onSubmit = () => {
// TODO: here you have to add the code
};
return (
<form onSubmit={onSubmit}>
<input
type="text"
placeholder="type your username"
name="username"
value={data.username}
onChange={handleChange}
/>
<br />
<input
type="text"
placeholder="type your password"
name="password"
value={data.password}
onChange={handleChange}
/>
<hr />
username: {data.username}
<br />
password: {data.password}
</form>
);
};
export default App;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment