SuperProgrammer775 / BATR-Games-Web

This website is an eCommerce website made with react.
0 stars 0 forks source link

TypeError: Object(...) is not a function #1

Open SuperProgrammer775 opened 4 years ago

SuperProgrammer775 commented 4 years ago

withAuth.js:

import useAuth from "../customHooks/index.js"; import { withRouter } from "react-router-dom";

const WithAuth = (props) => useAuth(props) && props.children;

export default withRouter(WithAuth);

useAuth.js:

import { useEffect } from "react"; import { useSelector } from "react-redux";

const mapState = ({ user }) => ({ currentUser: user.currentUser, });

export const useAuth = (props) => { const { currentUser } = useSelector(mapState);

useEffect(() => { if (!currentUser) { props.history.push("/login"); } }, [currentUser]);

return currentUser; };

index.js:

import { useAuth } from "./useAuth.js";

export default { useAuth };

plz help🙏

SuperProgrammer775 commented 4 years ago

Link 2 file errors: LINK