Search code examples
react-nativecomponents

How can I get the text / value of a textinput by its ref?


In my parent I have this code: enter image description here

So I render inside it my custom inputs by this way:

enter image description here

My doubt is how I can access on any part of this parent the text of each input using the ref. Someone can help me?

The textinput component:

https://gist.github.com/ThallyssonKlein/4e054bc368ebc153fbf9222e304ff887


Solution

  • I couldn't solve the problem, apparently there is no way to get this property in pure React-Native.

    So I started using the TextInput component of the react-native-paper package. This way the same code worked, I can get the text now with this excerpt:

    console.log(refContainerStep1.current.state.value);