How to read input field value in reactjs

Read input field value in reactjs using react hook

Example

import React, { useState } from "react";

export default function App() {

  const [name, setName] = useState();

  return (
    <>

     <p>{name}</p> 

      <input

        type="text"

        onChange={(e) => setName(e.target.value)}

        placeholder="Type your name"

      ></input>

    </>
  );
}

 

About Author

Photo

Hi, I am Mahbub Hasan
Software Engineer

I am very much interested to share my programming
and development knowledge with the people.I will try
to update my blog everyday with new technology inshallah.

Thank You

For Visiting My Blog.

Contact Me