Quantcast
Channel: Active questions tagged react-native+typescript - Stack Overflow
Viewing all articles
Browse latest Browse all 6287

How to create a form in react native?

$
0
0

I am creating a registration form in React Native. Currently, I am using useState() hook for each field:

  const [firstName, setFirstName] = useState("");  const [lastName, setLastName] = useState("");  const [phoneNumber, setPhoneNumber] = useState("");  const [userEmail, setUserEmail] = useState("");  const [userPassword, setUserPassword] = useState("");

This way does the job, but is it the correct one? Is it possible to manage it by using a single useState() instead of having state one for each field? Should I use package react-hook-form or another package?

Edit:

  const [registerForm, setRegisterForm] = useState({    firstName: "",    lastName: "",    phoneNumber: "",    userEmail: "",    userPassword: ""  });

This way would also work.


Viewing all articles
Browse latest Browse all 6287

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>