Skip to content
This repository has been archived by the owner on Sep 11, 2019. It is now read-only.

Error with implementation - this.props.routeGuard.shouldRoute is not a function #2

Open
Zaylril opened this issue Nov 8, 2017 · 1 comment

Comments

@Zaylril
Copy link

Zaylril commented Nov 8, 2017

Hi,

When trying to implement this I have the following code (

import React from 'react';
import { Route, Switch, withRouter } from 'react-router-dom';
import { SecureRoute } from 'react-route-guard';

class UserRouteGuard {
  shouldRoute() {
    const resultFromSyncApiCall = true;
    return resultFromSyncApiCall;
  }
}

<Switch>
   <SecureRoute
         path="/"
         component={EntryStep}
         routeGuard={UserRouteGuard}
       />
</Switch>

However I get the following error:

this.props.routeGuard.shouldRoute is not a function

Am I doing something wrong with the implementation?

Thanks!

@tstirrat
Copy link

I fixed it with new:

<SecureRoute
    path="/"
    component={EntryStep}
    routeGuard={new UserRouteGuard()}
/>

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

2 participants