All files / src/containers HomeContainer.jsx

88.89% Statements 8/9
50% Branches 1/2
100% Functions 4/4
88.89% Lines 8/9
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25          3x 5x   1x 1x 1x           3x 1x           2x  
import React, { Component } from "react";
import { connect } from "react-redux";
import { Redirect } from "react-router-dom";
import { isAuth } from "../redux/middleware";
 
export const HomeContainer = AuthenticatedComponent =>
  class HomeContainer extends Component {
    render() {
      const { isAuth } = this.props;
      Eif (!isAuth) {
        return <Redirect to={process.env.PUBLIC_URL + "/login"} />;
      }
      return <AuthenticatedComponent {...this.state} {...this.props} />;
    }
  };
 
const mapStateToProps = state => {
  return {
    isAuth: isAuth(state)
  };
};
 
export default authenticatedComponent =>
  connect(mapStateToProps)(HomeContainer(authenticatedComponent));