dispatching redirect on client fires two actions
See original GitHub issueGiven 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:
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:
- Created 6 years ago
- Comments:11 (6 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
fyi, i’ve reproduced this. i’ll fix it.
I will be working on a test project to duplicate soon, FYI.