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

Popular posts from this blog

Send Data Child to Parent Component - React Js

Hide , Show and Toggle in ReactJs

Importance Of Web Content In SEO.