Skip to content

Instantly share code, notes, and snippets.

View njwest's full-sized avatar
🎹
Groovin

Nick West 韋羲 njwest

🎹
Groovin
View GitHub Profile
@njwest
njwest / LoggedIn.js
Created March 24, 2018 12:53
screens/LoggedIn.js
import React, { Component } from 'react';
import { View } from 'react-native';
import { Button } from '../components/common/';
export default class LoggedIn extends Component {
constructor(props){
super(props);
}
render() {
@njwest
njwest / Login.js
Created March 24, 2018 12:38
components/Login.js onLoginFail
# snip
class Login extends Component {
constructor(props){
# code omitted
this.loginUser = this.loginUser.bind(this);
this.onLoginFail = this.onLoginFail.bind(this);
}
@njwest
njwest / Registration.js
Last active March 24, 2018 12:26
components/Registration.js Error Handler
#snip
class Registration extends Component {
constructor(props){
# code omitted
this.registerUser = this.registerUser.bind(this);
this.onRegistrationFail = this.onRegistrationFail.bind(this);
}
@njwest
njwest / Login.js
Last active March 24, 2018 12:21
components/Login.js loginUser func
# snip
import axios from 'axios';
import deviceStorage from '../services/deviceStorage';
class Login extends Component {
constructor(props){
super(props);
this.state = {
email: '',
@njwest
njwest / Registration.js
Last active March 23, 2018 07:12
src/components/Registration.js part X
# snip
axios.post("http://localhost:4000/api/v1/sign_up",{
user: {
email: email,
password: password,
password_confirmation: password_confirmation
}
},)
.then((response) => {
@njwest
njwest / Auth.js
Last active March 23, 2018 07:08
screens/Auth.js Part something
# snip
whichForm() {
if(!this.state.showLogin){
return(
<Registration newJWT={this.props.newJWT} authSwitch={this.authSwitch} />
);
} else {
return(
<Login newJWT={this.props.newJWT} authSwitch={this.authSwitch} />
@njwest
njwest / App.js
Last active March 23, 2018 07:10
src/App.js newJWT(jwt) func
# snip
export default class App extends Component {
constructor() {
super();
this.state = {
jwt: '',
loading: true
}
@njwest
njwest / Registration.js
Created March 23, 2018 06:44
components/Registration.js Part IX
import React, { Component, Fragment } from 'react';
import { View, Text } from 'react-native';
import { Input, TextLink, Loading, Button } from './common';
import axios from 'axios';
import deviceStorage from '../services/deviceStorage'; # Import deviceStorage :)
# snip
@njwest
njwest / deviceStorage.js
Last active March 23, 2018 02:59
src/services/deviceStorage.js Part II
# snip
const deviceStorage = {
async saveItem(key, value) {
try {
await AsyncStorage.setItem(key, value);
} catch (error) {
console.log('AsyncStorage Error: ' + error.message);
}
}
@njwest
njwest / deviceStorage.js
Created March 23, 2018 02:55
src/services/deviceStorage.js Part I
import { AsyncStorage } from 'react-native';
const deviceStorage = {
// our AsyncStorage functions will go here :)
};
export default deviceStorage;