ソースを参照

useAuth hook

new-app
Lazar Kostic 3年前
コミット
a255a565dc

+ 1
- 1
components/CustomDrawer/CustomDrawer.jsx ファイルの表示

@@ -16,7 +16,7 @@ import { MaterialIcons } from "@expo/vector-icons";
import { Ionicons } from "@expo/vector-icons";
import { useDispatch } from "react-redux";
import { logoutUser } from "../../store/actions/login/loginActions";
import useAuthHook from "../../utils/hooks/useAuthHook";
import useAuthHook from "../../hooks/useAuthHook";

const CustomDrawer = (props) => {


utils/hooks/useAuthHook.js → hooks/useAuthHook.js ファイルの表示

@@ -1,9 +1,9 @@
import React from "react";
import * as Google from "expo-auth-session/providers/google";
import { getData } from "../../service/asyncStorage";
import { ACCESS_TOKEN } from "../../constants/localStorage";
import { getData } from "../service/asyncStorage";
import { ACCESS_TOKEN } from "../constants/localStorage";
import { revokeAsync } from "expo-auth-session";
import variables from "../variables";
import variables from "../utils/variables";

const useAuthHook = () => {
const [request, response, promptAsync] = Google.useAuthRequest({

+ 1
- 1
screens/LoginScreen.jsx ファイルの表示

@@ -29,7 +29,7 @@ import {
import { selectIsLoadingByActionType } from "../store/selectors/loadingSelectors";
import { LOGIN_USER_SCOPE } from "../store/actions/login/loginActionConstants";
import { fetchAuthProvider } from "../store/actions/authProvider/authProviderActions";
import useAuthHook from "../utils/hooks/useAuthHook";
import useAuthHook from "../hooks/useAuthHook";
import { storeData } from "../service/asyncStorage";
import { ACCESS_TOKEN } from "../constants/localStorage";


+ 1
- 1
screens/RegisterScreen.jsx ファイルの表示

@@ -33,7 +33,7 @@ import {
clearRegisterErrors,
registerUser,
} from "../store/actions/register/registerActions";
import useAuthHook from "../utils/hooks/useAuthHook";
import useAuthHook from "../hooks/useAuthHook";
import { fetchAuthProvider } from "../store/actions/authProvider/authProviderActions";
import { ACCESS_TOKEN } from "../constants/localStorage";
import { storeData } from "../service/asyncStorage";

+ 8
- 2
screens/SettingsScreen.jsx ファイルの表示

@@ -1,10 +1,16 @@
import React from 'react';
import { View, Text, StyleSheet } from 'react-native';
import { View, Text, StyleSheet, TouchableOpacity } from 'react-native';

const SettingsScreen = () => {
const SettingsScreen = ({navigation}) => {
return (
<View style={styles.container}>
<Text>Settings</Text>
<TouchableOpacity onPress={() => navigation.goBack()}>
<Text>Go Back</Text>
</TouchableOpacity>
<TouchableOpacity onPress={() => navigation.openDrawer()}>
<Text>Open drawer</Text>
</TouchableOpacity>
</View>
)
}

+ 18
- 20
store/middleware/loadingMiddleware.js ファイルの表示

@@ -5,26 +5,24 @@ import {
SUCCESS,
UPDATE,
SUBMIT,
} from '../actions/actionHelpers';
import { addLoader, removeLoader } from '../actions/app/appActions';
} from "../actions/actionHelpers";
import { addLoader, removeLoader } from "../actions/app/appActions";

const promiseTypes = [FETCH, UPDATE, DELETE, SUBMIT];
export default ({ dispatch }) => (next) => (action) => {
const promiseType = promiseTypes.find((promiseType) =>
action.type.includes(promiseType),
);
if (promiseType) {
dispatch(addLoader(action.type));
return next(action);
}
export default ({ dispatch }) =>
(next) =>
(action) => {
const promiseType = promiseTypes.find((promiseType) =>
action.type.includes(promiseType)
);
if (promiseType) {
dispatch(addLoader(action.type));
return next(action);
}

if (action.type.includes(SUCCESS) || action.type.includes(ERROR)) {
// const actionType = action.type.includes(SUCCESS)
// ? action.type.replace(SUCCESS, '[LOADING]')
// : action.type.replace(ERROR, '[LOADING]');

dispatch(removeLoader(action.type));
return next(action);
}
next(action);
};
if (action.type.includes(SUCCESS) || action.type.includes(ERROR)) {
dispatch(removeLoader(action.type));
return next(action);
}
next(action);
};

読み込み中…
キャンセル
保存