-
Class component with controlled components.
-
Class Component with un-controlled components.
-
Functional component with controlled components.
-
Functional component with un-controlled components.
-
Class component with controlled components -> For each element we will be maintaining state and when any change is done for that element we will be updating the state for that element.
this.state = { email: "", password: "" }; In this case, we have a state for the email. handleEmailChange(e) { this.setState({ email: e.target.value }); } We are updating the state only for that particular element. For more info. Please check in src/ClassControlled/ClassControlled.jsx file
-
Class component with un-controlled components -> For each element we will create a reference (using createRef) and then for the element we will provide the reference created, the DOM will handle the element updation.
this.email = React.createRef(); In this case, we do not need to write any event handling, because DOM will take care of that. By using this way we can access the current value for that reference -> ${this.email?.current?.value} For more info. Please check in src/ClassUnControlled/ClassUnControlled.jsx file
-
Functional component with controlled components -> For each element we will be maintaining state and when any change is done for that element we will be updating the state for that element.
const [email, setEmail] = useState(""); In this case, we have a state for the email. onChange={(e) => setPassword(e.target.value)} We are updating the state only for that particular element. For more info. Please check in src/FunctionalControlled/FunctionalControlled.jsx file
-
Functional component with un-controlled components -> For each element we will create a reference (using createRef) and then for the element we will provide the reference created, the DOM will handle the element updation.
const emailRef = useRef(); In this case, we do not need to write any event handling, because DOM will take care of that. By using this way we can access the current value for that reference -> ${emailRef.current.value} For more info. Please check in src/FunctionalUnControlled/FunctionalUnControlled.jsx file
-
Notifications
You must be signed in to change notification settings - Fork 0
vardhan-venkata/react-forms
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
About
No description, website, or topics provided.
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published