question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

dispatching redirect on client fires two actions

See original GitHub issue

Given this code in my options:

export default {
    onBeforeChange: (dispatch, getState, action) => {
        if( action.type !== 'LOGIN' ) {
            const loginAction = {type: 'LOGIN'};
            const _loginRedirect = redirect( loginAction );
            dispatch( _loginRedirect );
        }
    }
}

With these routes:

export default {
    HOME: '/',
    FORGOT_PASSWORD: '/forgot-password',
}

Why does dispatching {type: 'FORGOT_PASSWORD'} result in two HOME actions being fired? Both appear identical and happen near instantaneously:

doublehome

Is this something I am causing to happen? Is it intentional? If so, what is the rationale behind it. Just curious if there’s some benefit to it being called twice, or if it’s a bug.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:11 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
faceyspaceycommented, Aug 18, 2017

fyi, i’ve reproduced this. i’ll fix it.

1reaction
veddermaticcommented, Aug 9, 2017

I will be working on a test project to duplicate soon, FYI.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to redirect from an action event in redux - Stack Overflow
In your component that is firing the action creator: import { withRouter } from "react-router-dom". Then at the bottom of the code, ...
Read more >
trubo:load gets triggered twice when GET request is a redirect ...
We have pages that once turbo:load fires, dispatch JS POST requests that update the model's lock_version (Rails's OptimisticLocking).
Read more >
Re: Embedded app Redirect not working - Shopify Community
The app is error free ready to submit to the store, otherwise working except the Redirect isn't firing (or the dispatch action, I'm...
Read more >
How to Transition to Another Route on Successful Async ...
In this guide, we will use a Redux action to redirect the user using the <Redirect /> component. We will dispatch an action...
Read more >
Redirections in HTTP - MDN Web Docs - Mozilla
URL redirection, also known as URL forwarding, is a technique to give more than one URL address to a page, a form, or...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found