reactjs/react-router-redux

about goBack and go(-1)

HengCC opened this issue · 1 comments

i wrote a redux middleware , when @@router/LOCATION_CHANGE was triggered , i did the operation below.

if (action.type === '@@router/LOCATION_CHANGE') {
  if (action.payload && action.payload.pathname === '/somePath') {
      // set some other params to store.
      store.dispath(anotherAction)
  }
  next(action)
}

when the path changed from '/pathA' to '/pathB?query=xxxx', and then changed to '/pathC'
i continuous call go(-1) or goBack(). In theory it should be pathC->pathB?query=xxxx->pathA,
but the actual situation is pathC->pathB?query=xxxx->pathC->pathB?query=xxxx.........

i changed the code like this then it will work fine.

if (action.type === '@@router/LOCATION_CHANGE') {
  next(action)
  if (action.payload && action.payload.pathname === '/somePath') {
      // set some other params to store.
      store.dispath(anotherAction)
  }
}

I do not know why this is.

This is a bug tracker, not a support system. For usage questions, please use Stack Overflow or Reactiflux where there are a lot more people ready to help you out. Thanks!