I think he's just copying and pasting. But yeah the clue level is very low.
Sooooo - since I've now inherited this thing, I have a somewhat noobish react question. We're using BrowserRouter and wrapping our components with withRouter - I think just so we can use props.history.push to route. Might change that but that's not the question.
The question is I have a common behavior that happens after successful login or sign up - we need to go to the back end CRM system, see if we can find the user, and route them to one page if they have a CRM ID and a different page if they don't. There are also other edge cases that get routed to other pages. Because of the vagaries of Cognito and how it integrates with the browser, I cannot just get this info from the back end when the user signs up. It has to be in a separate call.
So obviously I want to consolidate this behavior somewhere and share it amongst all the different ways and places a user can login or sign up.
- I could pass the props object to my service that looks up the CRM ID, and have it do the routing. But that doesn't seem like something a service should do.
- I could go vanilla old school and just make some shared utility method.
- I could wrap the components in some more global component that has a method I can call to do the post login behavior/routing.
- Or I could have something at the global state that gets triggered when I do something like setState({userLoggedIn: true});
The last seems like the most react-y way to do things. But it also bugs me in code when magic happens like that. How do I trace what's supposed to happen when userLoggedIn = true triggers something? Seems painful.
Edit: I thought of a 5th way that I might like. Redirect to a SignUpSuccess page that is just a spinner. That page makes the call to the back end and figures out where to route the user. Hmmm.
Last edited by suzzer99; 01-30-2019 at 08:52 PM.