Skip to content

Instantly share code, notes, and snippets.

@themojilla
themojilla / authHOC.js
Created April 14, 2018 19:36
HOC wrapper for react-router-config routes
import React from 'react';
import { connect } from 'react-redux';
import { Redirect } from 'react-router-dom';
export default ChildComponent => {
class RequireAuth extends React.PureComponent {
render() {
switch (this.props.isAuthenticated) {
case false:
return <Redirect to="/login" />;