Skip to content

Commit

Permalink
Merge pull request #357 from MetroStar/recoil-refactor
Browse files Browse the repository at this point in the history
Refactor Recoil Use
  • Loading branch information
jbouder authored Oct 26, 2024
2 parents 6eea86a + 3e8b066 commit 6704f99
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/hooks/use-auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@ import { useEffect, useState } from 'react';
import { useAuth as useKeycloakAuth } from 'react-oidc-context';
import { useRecoilState } from 'recoil';
import { userData } from '../data/user';
import { currentUser, signedIn } from '../store';
import { currentUserState, signedInState } from '../store';
import { User } from '../types/user';

const useAuth = () => {
const auth = useKeycloakAuth();
const [isSignedIn, setIsSignedIn] = useRecoilState<boolean>(signedIn);
const [isSignedIn, setIsSignedIn] = useRecoilState<boolean>(signedInState);
const [isLoading, setIsLoading] = useState<boolean>(true);
const [error, setError] = useState<string | null>();
const [currentUserData, setCurrentUserData] = useRecoilState<
User | undefined
>(currentUser);
>(currentUserState);

/* TODO: Uncomment for interacting with own API, no need to send tokens to external public API */
// useEffect(() => {
Expand Down
6 changes: 3 additions & 3 deletions src/store.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { User } from '@src/types/user';
import { atom } from 'recoil';

const signedIn = atom({
const signedInState = atom({
key: 'signedIn',
default: false,
});

const currentUser = atom<User | undefined>({
const currentUserState = atom<User | undefined>({
key: 'currentUser',
default: undefined,
});

export { currentUser, signedIn };
export { currentUserState, signedInState };

0 comments on commit 6704f99

Please sign in to comment.