import React, { Component } from 'react'
import { Route, Redirect } from 'react-router-dom'
import configureStore from '../store/ConfigureStore'

let store = configureStore()
const ProtectedRoute = ({ component: Component, ...rest }) => {
  let state = store.getState()
  return (<Route { ...rest } render={(props) => {
    return state.login.user
    ? <Component {...props} />
    : <Redirect to='/login' />
  }}
  />)
}

export default ProtectedRoute
import React, { Component } from 'react'
import { Route, Redirect } from 'react-router-dom'
import configureStore from '../store/ConfigureStore'

let store = configureStore()
const ProtectedRoute = ({ component: Component, ...rest }) => {
  let state = store.getState()
  console.log('Blocking..')
  return (<Route { ...rest } render={(props) => {
    return Object.keys(state.login.user).length !== 0
    ? <Component {...props} />
    : <Redirect to='/login' />
  }}
  />)
}

export default ProtectedRoute
Verify contents of user object.
Verify contents of user object.
