Month: March 2019

How to get input text • React Native

In this article we will see how to get the user input text inside the <TextInput>, very simply.
In this example, we will be using a login page :

Login page

Add the reference for each TextInput at the top of your login class, inside the constructor :

Add references with React.createRef()

Then, put the ref tag inside the each TextInput.
Attribute this ref tag to each variable that have been referenced. Here is the example with this.logInput :

add the ref tag

Now you can get the value by using this.logInput.current._lastNativeText inside our code.