I want to create a form without using useState to control the inputs because I only need the inputs values when the user presses the button, so I want to access/know the input value at that time only. I also think that updating the screen after each text input is not a good practice.
Let's assume that we have the following structure:
const Home = () => { // const [inputValue, setInputValue] = useState(""); => I want to avoid that const inputRef = useRef<TextInput>(null); return (<View><TextInput style={styles.input} ref={inputRef} // value={inputValue} => I want to avoid that // onChangeText={(text) => setInputValue(text)} => I want to avoid that /></View> );};
We all know that when we have one TextInput on screen, we can type in it, without specifying the value prop and onChangeText, that we would normally use useState for that.
What I want to do is simply access the text that was input, and I would use a ref for that using useRef hook, but the problem is that using useRef I have access to TextInput props but the value is undefined because I am not specifying that. Am I missing something or there is no way to do that without using a useState for defining a value and onChangeText?