Unfortunately, I cannot create my own route with the reaction router version 4 . I am trying to build a route that displays the component if the user is authenticated or redirects the user to the login component in another case.
I started using this documentation page to get started.
const ProtectedRoute = ({component, ...rest}) => ( <Route {...rest} render={props => false ? <Component {...props} /> : <Redirect to={{pathname: '/login', state: {from: props.location}}}/>} /> );
I use this ProtectedRoute as follows:
<ProtectedRoute exact path='/' component={testComponent}/>
When I run this, I get the following runtime error:
Uncaught ReferenceError: __rest is not defined at ProtectedRoute (index.tsx:19) at ReactCompositeComponent.js:305 at measureLifeCyclePerf (ReactCompositeComponent.js:75) at ReactCompositeComponentWrapper._constructComponentWithoutOwner (ReactCompositeComponent.js:304) at ReactCompositeComponentWrapper._constructComponent (ReactCompositeComponent.js:279) at ReactCompositeComponentWrapper.mountComponent (ReactCompositeComponent.js:187) at Object.mountComponent (ReactReconciler.js:45) at ReactDOMComponent.mountChildren (ReactMultiChild.js:236) at ReactDOMComponent._createInitialChildren (ReactDOMComponent.js:703) at ReactDOMComponent.mountComponent (ReactDOMComponent.js:522)
Here is some more info on the stack I'm using:
- respond 15.6.1
- response-router-dom 4.2.2
- typescript 2.5.2
Why is rest not defined? What is wrong with my user route?
Thank you in advance!
Update (minimal example)
Below is a minimal example of the problem here . To run the example, do the following:
Robin source share