Skip to content
This repository was archived by the owner on Oct 26, 2018. It is now read-only.
This repository was archived by the owner on Oct 26, 2018. It is now read-only.

about goBack and go(-1) #621

@HengCC

Description

@HengCC

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions