Skip to content

Instantly share code, notes, and snippets.

@tricoder42
Created June 6, 2017 19:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save tricoder42/f3ef207ee6bcd957bf9eae6f1a15819c to your computer and use it in GitHub Desktop.
Save tricoder42/f3ef207ee6bcd957bf9eae6f1a15819c 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