Hari 27: Auth pada React Native (2)

Search for a command to run...

No comments yet. Be the first to comment.
Belajar full stack JavaScript selama ramadhan tahun 2021 - Javascript Dasar - Javascript Backend - Javascript Frontend - Javascript Mobile https://youtu.be/gf_Fssu623U
Besi hitam tumpul yang dipukul, bakar, pukul, bakar, asah, pukul, bakar, asah hingga menjadi pedang yang tajam. Jika Anda ingin jadi hebat setajam pedang yah.... Bg Asrul, materinya udah hampir selesai tapi kok ditanggung? Bukan gitu anak muda, sese...
Waktu dapet kerjaan pertama sebagai front-end dev di dusdusaan.com (2019), aku dikasih project pake React, seingat gue aplikasinya tentang reseller dimana fitur yg saya kerjakan adalah tentang point dan event para reseller. Jujur aja, waktu itu aku b...

Awal mula gue pake TypeScript itu sebenernya bukan karena inisiatif sendiri, tapi karena kepepet. Waktu itu kantor lagi ngembangin dashboard chatbot buat tim CS, dan project-nya udah jalan duluan pake TypeScript. Gue yang baru masuk tim, langsung dis...

Javascript

Terkadang kita mendapatkan data bilangan misal response saat nge-hit API ke backend kita sendiri atau saat menggunakan third-party API anggap saja Xendit atau Midtrans tetapi berbentuk string. Seperti contoh dibawah ini. { "data": { "total_bela...

Cerita Mentor

Kita telah membuat fitur login sebelumnya, sekarang kita lanjutkan dengan fitur register karena sebelumnya akun untuk login telah dibuatkan dari sisi backendnya sehingga dapat langsung dipakai.
Buat file pages/Register.js yang isi kodenya seperti berikut.
import React, { useState } from "react";
import {
Container,
Header,
Body,
Title,
Content,
Text,
Form,
Label,
Input,
Button,
Item,
Right,
} from "native-base";
import { Link } from "react-router-native";
import { useDispatch } from "react-redux";
import { createUser } from "../actions/user.action";
const Register = (props) => {
const dispatch = useDispatch();
const [user, updateUser] = useState({});
const submitForm = () => {
dispatch(createUser(user)).then((res) => {
props.history.push("/");
});
};
return (
<Container>
<Header>
<Body>
<Title>Register</Title>
</Body>
</Header>
<Content style={{ padding: 16 }}>
<Right>
<Text style={{ fontSize: 32 }}>Register 30 Hari Js</Text>
</Right>
<Form>
<Item floatingLabel>
<Label>Nama</Label>
<Input
onChangeText={(text) => updateUser({ ...user, name: text })}
/>
</Item>
<Item floatingLabel>
<Label>Label</Label>
<Input
onChangeText={(text) => updateUser({ ...user, label: text })}
/>
</Item>
<Item floatingLabel>
<Label>Link Profile</Label>
<Input
onChangeText={(text) => updateUser({ ...user, picture: text })}
/>
</Item>
<Item floatingLabel>
<Label>Email</Label>
<Input
onChangeText={(text) => updateUser({ ...user, email: text })}
/>
</Item>
<Item floatingLabel>
<Label>Phone</Label>
<Input
onChangeText={(text) => updateUser({ ...user, phone: text })}
/>
</Item>
<Item floatingLabel>
<Label>Website</Label>
<Input
onChangeText={(text) => updateUser({ ...user, website: text })}
/>
</Item>
<Item floatingLabel>
<Label>Summary</Label>
<Input
onChangeText={(text) => updateUser({ ...user, summary: text })}
/>
</Item>
<Item floatingLabel last>
<Label>Password</Label>
<Input
secureTextEntry={true}
onChangeText={(text) => updateUser({ ...user, password: text })}
/>
</Item>
<Button
style={{
marginTop: 16,
marginBottom: 16,
flex: 1,
justifyContent: "center",
alignItems: "center",
}}
onPress={submitForm}
>
<Text style={{ textAlign: "center" }}> Register </Text>
</Button>
<Link to={"/"}>
<Text> Login </Text>
</Link>
</Form>
</Content>
</Container>
);
};
export default Register;
Hasil akan seperti berikut.
