Last active
February 8, 2023 09:31
-
-
Save dabit3/1c6b1808c9bdf10138f51dae46418d8c to your computer and use it in GitHub Desktop.
SignUp form in React Native Navigation - V2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SignUp.js | |
import React from 'react' | |
import { | |
View, | |
Button, | |
TextInput, | |
StyleSheet | |
} from 'react-native' | |
export default class SignUp extends React.Component { | |
state = { | |
username: '', password: '', email: '', phone_number: '' | |
} | |
onChangeText = (key, val) => { | |
this.setState({ [key]: val }) | |
} | |
signUp = async () => { | |
const { username, password, email, phone_number } = this.state | |
try { | |
// here place your signup logic | |
console.log('user successfully signed up!: ', success) | |
} catch (err) { | |
console.log('error signing up: ', err) | |
} | |
} | |
render() { | |
return ( | |
<View style={styles.container}> | |
<TextInput | |
style={styles.input} | |
placeholder='Username' | |
autoCapitalize="none" | |
placeholderTextColor='white' | |
onChangeText={val => this.onChangeText('username', val)} | |
/> | |
<TextInput | |
style={styles.input} | |
placeholder='Password' | |
secureTextEntry={true} | |
autoCapitalize="none" | |
placeholderTextColor='white' | |
onChangeText={val => this.onChangeText('password', val)} | |
/> | |
<TextInput | |
style={styles.input} | |
placeholder='Email' | |
autoCapitalize="none" | |
placeholderTextColor='white' | |
onChangeText={val => this.onChangeText('email', val)} | |
/> | |
<TextInput | |
style={styles.input} | |
placeholder='Phone Number' | |
autoCapitalize="none" | |
placeholderTextColor='white' | |
onChangeText={val => this.onChangeText('phone_number', val)} | |
/> | |
<Button | |
title='Sign Up' | |
onPress={this.signUp} | |
/> | |
</View> | |
) | |
} | |
} | |
const styles = StyleSheet.create({ | |
input: { | |
width: 350, | |
height: 55, | |
backgroundColor: '#42A5F5', | |
margin: 10, | |
padding: 8, | |
color: 'white', | |
borderRadius: 14, | |
fontSize: 18, | |
fontWeight: '500', | |
}, | |
container: { | |
flex: 1, | |
justifyContent: 'center', | |
alignItems: 'center' | |
} | |
}) |
THANKS A LOT
Not that good. You should use react-native-paper.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Good design