Skip to content

Instantly share code, notes, and snippets.

@phpsmarter
Forked from tricoder42/02_anonymous_user.js
Created March 27, 2018 08:04
Show Gist options
  • Save phpsmarter/f7f56d39cff79de911ac9b2542325b4d to your computer and use it in GitHub Desktop.
Save phpsmarter/f7f56d39cff79de911ac9b2542325b4d to your computer and use it in GitHub Desktop.
2017/06/06 [Medium] Use Selectors in Redux for Great Good
const initialState = {
user: {
name: 'anonymous',
token: null
}
}
const getUser = state => state.user || {}
const isAuthenticated = state => Boolean(getUser(state).token)
const isAnonymous = state => !isAuthenticated(user)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment