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
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)
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?
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.
Did you remove this line as it talks about in the chapter?
this.props.history.push("/");
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.
Thanks for the heads up. Edited that line a bit.
If I try to access a noteId without being logged in I get successfully sent to the login page with the redirect link. However, I am then able to login as any user and see the note. Is this an error on my end, or just something not covered in this tutorial? I understand it’s a demo and not every little security hole needs to be patched up, just want to make sure I didn’t miss anything on my end.
Love the tutorial, it has taught me so much. Thank you for putting your time and effort in to this great resource!
No that shouldn’t happen. Can you try this on the hosted demo: