Skip to content

Instantly share code, notes, and snippets.

@dabit3
Last active February 8, 2023 09:31
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 7 You must be signed in to fork a gist
  • Save dabit3/1c6b1808c9bdf10138f51dae46418d8c to your computer and use it in GitHub Desktop.
Save dabit3/1c6b1808c9bdf10138f51dae46418d8c to your computer and use it in GitHub Desktop.
SignUp form in React Native Navigation - V2
// 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'
}
})
@Byusa
Copy link

Byusa commented Dec 10, 2020

Good design

@Sprinkles1511
Copy link

THANKS A LOT

@Irfanwani
Copy link

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