Skip to content

Instantly share code, notes, and snippets.

@mentix02
Created December 2, 2020 00:24
Show Gist options
  • Save mentix02/e61e50195f83955d477d7776af4fc0ee to your computer and use it in GitHub Desktop.
Save mentix02/e61e50195f83955d477d7776af4fc0ee to your computer and use it in GitHub Desktop.
import { useSelector } from "react-redux";
import { AuthState } from "./types";
export const useAuthenticated = (): boolean =>
useSelector(({ auth }: { auth: AuthState }) => auth.isAuthenticated);
export const useToken = (): string | undefined =>
useSelector(({ auth }: { auth: AuthState }) => auth.token);
export const useUsername = (): string | undefined =>
useSelector(({ auth }: { auth: AuthState }) => auth.username);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment