Skip to content

Instantly share code, notes, and snippets.

@aam-himel
Created September 14, 2023 16:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aam-himel/91ea70e4fe6b4c6a6c95c70bb6be83e3 to your computer and use it in GitHub Desktop.
Save aam-himel/91ea70e4fe6b4c6a6c95c70bb6be83e3 to your computer and use it in GitHub Desktop.
#9 Mastering Event Handling in React | Complete React Course in Bangla
import { useState } from "react";
const App = () => {
const [localValue, setLocalValue] = useState("");
const [submittedValue, setSubmittedValue] = useState("");
const handleChange = (event) => {
setLocalValue(event.target.value);
};
const handleSubmitForm = (event) => {
event.preventDefault();
setSubmittedValue(localValue);
};
return (
<div>
<h1>Video No. 09 </h1>
<form onSubmit={handleSubmitForm}>
<input
type="text"
placeholder="input"
value={localValue}
onChange={handleChange}
/>
<button type="submit">Submit</button>
</form>
<h1>Final Submitted Value: {submittedValue}</h1>
</div>
);
};
export default App;
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
height: 100vh;
padding-top: 3rem;
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
gap: 1rem;
}
input {
padding: 1rem 2rem;
font-size: 1.5rem;
background-color: white;
}
form {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
gap: 1rem;
}
button {
padding: 1rem 2rem;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment