Redux 小路由器支持 react router v6

问题描述 投票:0回答:0

`当我升级到 React 路由器版本 6 时,与 redux 一起使用的小路由器出现历史问题,但没有监听 URL 更改。历史就是这样

import createbrowserHistory from "history"
const browserHistory = createBrowserHistory()  

下面是我的中间件,用于在 react-router 将新项目推送到 react-router 浏览器历史记录时同步 redux-little-router。它没有进入我的中间件。Redux Little Router 是一个库,它允许开发人员将路由集成到他们的 Redux 应用程序中,同时将路由状态保持在 Redux 存储中。

import { createBrowserHistory } from 'history'
import { replace } from 'redux-little-router'

export default (store) =\> {
const browserHistory = createBrowserHistory()
browserHistory.listen((location) =\> {
if (location.action !== 'POP') {
store.dispatch(replace({ ...location }))
}
})
return (next) =\>
(action) =\>
next(action)
}

请帮助我如何将 redux-little-router 历史记录与 React 路由器版本 6 历史记录同步。 URL 更改未监听。 是否对 react-redux 和 redux 有任何依赖。 我正在使用 react redux 版本 8 和 redux 版本 3.`

javascript reactjs redux react-router html5-history
© www.soinside.com 2019 - 2024. All rights reserved.