close

How to get the value of an input field using ReactJS?

Hello Guys, How are you all? Hope You all Are Fine. Today we are going to learn How to get the value of an input field using ReactJS? in javascript. So Here I am Explain to you all the possible methods here.

Without wasting your time, Let’s start This Article.

How to get the value of an input field using ReactJS ?

  1. How to get the value of an input field using ReactJS ?

    to get the value of an input field using ReactJS In react 16, I use
    <Input id="number" type="time" onChange={(evt) => { console.log(evt.target.value); }} />

  2. How to get the value of an input field using ReactJS ?

    to get the value of an input field using ReactJS In react 16, I use
    <Input id="number" type="time" onChange={(evt) => { console.log(evt.target.value); }} />

Method 1

You should use constructor under the class MyComponent extends React.Component

constructor(props){
    super(props);
    this.onSubmit = this.onSubmit.bind(this);
  }

Then you will get the result of title

Method 2

In react 16, I use

<Input id="number" 
       type="time" 
       onChange={(evt) => { console.log(evt.target.value); }} />

Summery

It’s all About this article. Hope all method helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which method worked for you? Thank You.

Leave a Comment