Using layout with "withAuthenticationRequired"

We’ve just switch to using Auth0 and I’m trying to update our existing code to work with a auth0 sample code that I got.
Here is what I have in App.js
return (


Here is what I have in PrivateRoute.js before using Auth0
function PrivateRoute ({ component: Component, …rest }) {
return (
render={props => (
<PrivateLayout {…props}>


Here is my PrivateLayout.js
return (

  <div className="wrapper">




        render={props => <Component {...props} />}



    <div className="main-panel">


      <div className="bottom-spacing" />





Now I’m tryin to integrate with following sample code having hard time being able to render the component with the PriavetLayout:
import React from “react”;
import { Route } from “react-router-dom”;
import { withAuthenticationRequired } from “@auth0/auth0-react”;
import { Loading } from “…/components/index”;
const ProtectedRoute = ({ component, …args }) => (
component={withAuthenticationRequired(component, {
onRedirecting: () => ,
export default ProtectedRoute;

Would appreciate all the help.

Hi @alex.farokhyans,

Welcome to the Community!

Are you using the React Quickstart? Auth0 React SDK Quickstarts: Login

Hi Stephanie,
I’ve been using that as reference, I’m trying to integrate auth0 with our existing react application that uses Azure B2C.

Okay, that’s good! The Quickstart is a good place to refer to. I’d also recommend this blog: The Complete Guide to React User Authentication with Auth0

Are there any errors?

Does it look like the using is authenticated? To determine this, you can import the useAuth0 hook and log isAuthenticated like this:

import { useAuth0 } from "@auth0/auth0-react";

const AuthenticationButton = () => {
  const { isAuthenticated } = useAuth0();

  return isAuthenticated ? <LogoutButton /> : <LoginButton />;

export default AuthenticationButton;

Would you mind re-sharing your App.js? All that is showing it return ( )





    <Route component={Main} />







return (




        <Route exact path="/">

          <Redirect to="/instruments" />


        <PublicRoute path="/login" component={Login} />

        <PublicRoute path="/forgottenPassword" component={ForgottenPassword} />









        <PrivateRoute path="/files" component={/*requireAuth(Files)*/Files} />

        <PrivateRoute path="/incidents" component={/*requireAuth(Incidents)*/Incidents} />

        <PrivateRoute path="/actions" component={/*requireAuth(Actions)*/Actions} />

        {/* <PrivateRoute path="/apps" component={requireAuth(Apps)} /> */}