requirement is to check the login status through code
(not http status code, but custom) returned from the backend in request.js
. The following two ways have been tried. Although you can jump to the list page after login, the history.listen ()
model
cannot be triggered.
the first type
history.js
import createHistory from "history/createHashHistory"
const history = createHistory()
export default history
index.js
const app = dva({
history
})
use
history.push ("/ login")
second type
import { routerRedux } from "dva/router"
const { dispatch } = app._store
dispatch(routerRedux.push("/login"))
both of these methods can jump, but both will create a separate history, so listen ()
will fail.
version
"dva": "^2.1.0",
"react": "^16.2.0",
ask for help
how to solve this problem? Or is there a better way to deal with the failure of user login and re-login?