Redirect on Login


#1

From @jayair on Mon Apr 10 2017 01:08:29 GMT+0000 (UTC)

Link to chapter - http://serverless-stack.com/chapters/redirect-on-login.html

Copied from original issue: https://github.com/AnomalyInnovations/serverless-stack-com/issues/60


#2

Getting this warning, and I don’t see any async in UnathenticatedRoute

Warning: Can't perform a React state update on an unmounted component. This is a no-op, but it indicates a memory leak in your application. To fix, cancel all subscriptions and asynchronous tasks in the componentWillUnmount method.
in Login (at UnauthenticatedRoute.js:27)

#3

This means that there is a setState getting called after the component has been unmounted. On which step of the chapter are you seeing this?


#4

I’ve implemented the “Redirect on login” code… I get that warning when I log in (from logged out state). Enter email/password, click log in, spins while loading, and then I get that warning right before it navigates home.


#5

Did you remove this line as it talks about in the chapter?

this.props.history.push("/");

#6

This statement, IMHO, is misleading:

Now let’s update our Redirect component to use this when it redirects.

True, Redirect is a component, but it’s not “our’s”, it’s from react-router-dom. And true, it is that component’s code that must be modified, but wouldn’t it be clearer to direct the reader to “our” component, UnauthenticatedRoute, which includes Redirect?

Thanks for considering.


#7

Thanks for the heads up. Edited that line a bit.