Uncontrolled Component - React Js
App.js:
import React, {useRef} from "react";
import './App.css'
function App()
{
let inputRef=useRef(null)
let inputRef2=useRef(null)
function formHandle(e)
{
e.preventDefault()
console.warn("Value of Field 1 :", inputRef.current.value)
console.warn("Value of Text Field 2", inputRef2.current.value)
let input3=document.getElementById('input3').value
console.warn("Input field 3 value : ", input3)
}
return(
<div className="App">
<h1>UnControlled Component</h1>
<form onSubmit={formHandle}>
<input type="text" ref={inputRef} /> <br/><br/>
<input type="text" ref={inputRef2}/><br/> <br/>
<input type="text" id="input3"/><br/> <br/>
<button>Submit</button>
</form>
</div>
)
}
export default App;
Comments
Post a Comment