Sawtaytoes
9/20/2018 - 3:14 AM

IsAuthenticated component w/ ReduxConnection

Advanced use of ReduxConnection to compose other Redux-stateful components.

import React from 'react'
import { ReduxConnection } from '@ghadyani-framework/redux-components'

import { authInfoSelector } from '~/redux/auth/selectors'

const IsAuthenticated = ({
  children,
}) => (
  <ReduxConnection selector={authInfoSelector}>
    {({
      hasReceivedAuthInfo,
      isAuthenticated,
    }) => (
      hasReceivedAuthInfo
      && isAuthenticated
      && children
    )}
  </ReduxConnection>
)

export default IsAuthenticated