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.

react-router-redux Redirects no longer trigger an action to the reducer

See original GitHub issue

Version

react-router-redux@5.0.0-alpha.7 & react-router-redux@5.0.0-alpha.8

Summary

Redirects in a route nolonger trigger an action to the reducer.

Steps to reproduce

My routes setup.

const Routes = ({store}) => (
  <CoreLayout>
    <Switch>
      <Route exact={true} path='/' render={Routes.homeRedirect} />
      <Route path='/photos/:folder*' component={PhotoView} />
    </Switch>
  </CoreLayout>
)

Routes.homeRedirect = () => (
  <Redirect to='/photos' />
)

Expected Behavior

In version alpha.6 both the initial page load and the redirect are sent to the reducer.

{
  type: '@@router/LOCATION_CHANGE',
  payload: {
    pathname: '/',
    search: '',
    hash: ''
  }
}
{
  type: '@@router/LOCATION_CHANGE',
  payload: {
    pathname: '/photos',
    search: '',
    hash: '',
    key: 'mswocw'
  }
}

Actual Behavior

With version alpha.7 and 8 the only initial page load is sent to the reducer

{
  type: '@@router/LOCATION_CHANGE',
  payload: {
    pathname: '/',
    search: '',
    hash: ''
  }
}

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:16
  • Comments:21 (3 by maintainers)

github_iconTop GitHub Comments

11reactions
sturzynskicommented, Oct 25, 2017

Experiencing this issue as well.

Connected Router beings listening to history in componentDidMount and react-router Redirect performs the history push in componentDidMount as well. Because componentDidMount is called on children before the parent, there is a moment where a Redirect pushes a new history but the Connected Router is not yet listening to history.

7reactions
timdorrcommented, Dec 12, 2017

Alpha 9 is up. We’ll get this right at some point…

Read more comments on GitHub >

github_iconTop Results From Across the Web

react-router-redux Redirects no longer trigger an action to the ...
I have the similiar problem. In my case, action @@router/LOCATION_CHANGE triggered twice with different pathname in wrong order: first, with ...
Read more >
React router redirect after action redux - Stack Overflow
I want to redirect to page with registrationStep2. How can I do this? p.s. In history browser '/registrationStep2' has not been visited. This ......
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 ... Let's begin with action creators and...
Read more >
React Router with Redux: Understanding navigation state
Use React Router to declaratively navigate within your React and Redux applications and maintain state across your app's navigation ...
Read more >
Redirect On Action Strategy using redux | by Ofir G - Medium
ErrorRedirectReducer — A relatively small reducer, that activate on two actions, RedirectAction , RedirectDoneAction , and write their payload ...
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