Code Monkey home page Code Monkey logo

Comments (9)

gomezvillegasdaniel avatar gomezvillegasdaniel commented on June 11, 2024

I'm hands on it

from pantry-for-good.

gomezvillegasdaniel avatar gomezvillegasdaniel commented on June 11, 2024

@jspaine Hi, I don't find the SignIn response. I've inspected both this.props and this.props.signIn(this.state.email, this.state.password) call but it doesn't return anything, nor a promise. Could you help me pls?

from pantry-for-good.

jspaine avatar jspaine commented on June 11, 2024

Hi, the signIn function just dispatches a redux action which sets the fetching state in the auth store and makes the api call. When that returns a success/failure action is dispatched. So you just need to watch the store to see the current state.

Try looking with the redux devtools open.

from pantry-for-good.

gomezvillegasdaniel avatar gomezvillegasdaniel commented on June 11, 2024

ok, but I noticed that if I jump to the auth/SIGNIN_FAILURE with the redux devtools it already displays the error on the screen, so I think I need to know how to get the store from the component and see if the status response is 400, then jump to that state?

from pantry-for-good.

jspaine avatar jspaine commented on June 11, 2024

Oh yeah, it shows the error but then the CLEAR_FLAGS action clears it again. I don't know why that action is being dispatched then (and twice) but if you can stop that it should fix it.

from pantry-for-good.

kenjiO avatar kenjiO commented on June 11, 2024

I think this is what is going on the way the application is now:

Every time UserRouter renders it calls guestOrRedirect(SignIn). This results in both the GuestOrRedirect and SignIn components getting unmounted, re-created and then mounted again which dispatches the CLEAR_FLAGS action.

I think that we only want to have the GuestOrRedirect with SignIn component created one time. So either changing UserRouter to not call this repeatedly or changing guestOrRedirect to not create a new component each time should fix this.

from pantry-for-good.

gomezvillegasdaniel avatar gomezvillegasdaniel commented on June 11, 2024

Thanks. I've tried to singletonise the GuestOrRedirect class when the WrappedComponent is instance of SignIn, but the class is being redeclared each time the guestOrRedirect function is called, so I loss the singleton instance. I don't know any other way to do it.

from pantry-for-good.

kenjiO avatar kenjiO commented on June 11, 2024

I think moving the call to guestOrRedirect outside of the UserRouter function will fix this.

const guestOrRedirectSignIn = guestOrRedirect(SignIn)

const UserRouter = ({match}) =>
 <SwitchWithNotFound>
    .
    .
    .
    <Route path={`${match.url}/signin`} exact component={guestOrRedirectSignIn} />

If this does work we will probably want to look at using it with the other routes calling guestOrRedirect and userOrRedirect if similar issues are happening with them

from pantry-for-good.

gomezvillegasdaniel avatar gomezvillegasdaniel commented on June 11, 2024

It worked! No collateral effects and no similar issues in the other routes. Thanks.

from pantry-for-good.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.