diff options
-rw-r--r-- | App.tsx | 27 |
1 files changed, 9 insertions, 18 deletions
@@ -45,23 +45,9 @@ const App = () => { isValidPassword: true, }) - const validUserCheck = (val:string) => { - var validLength:boolean = val.trim().length >= 6 - - if (validLength) { - setData({ - ...data, - isValidUser: true - }); - } - else { - setData({ - ...data, - isValidUser: false - }) - } - } - + /* + Updates the state of username. Also verifies the input of the Username field. + */ const handleUsernameUpdate = (val:string) => { var validLength:boolean = val.trim().length >= 6 @@ -81,6 +67,9 @@ const App = () => { } } + /* + Updates the state of password. Also verifies the input of the Password field. + */ const handlePasswordUpdate = (val:string) => { var validLength:boolean = val.trim().length >= 8 @@ -100,6 +89,9 @@ const App = () => { } } + /* + Handler for the Let's Start button or the Go button on the keyboard. + */ const handleLogin = () => { if (data.isValidUser && data.isValidPassword) { Alert.alert(`My favorite Girl Scout Cookies are taggalongs! What are yours ${data.username}?`) @@ -134,7 +126,6 @@ const App = () => { keyboardType='ascii-capable' onChangeText={user => handleUsernameUpdate(user)} defaultValue={data.username} - onEndEditing={(val) => validUserCheck(val.nativeEvent.text)} onSubmitEditing={() => {passwordInput.current.focus()}} blurOnSubmit={false} /> |