Skip to content

Commit 492a5dc

Browse files
committed
expose router history
1 parent 69e2554 commit 492a5dc

File tree

3 files changed

+8
-9
lines changed

3 files changed

+8
-9
lines changed

redisinsight/ui/src/Router.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import React from 'react'
2-
import { BrowserRouter } from 'react-router-dom'
2+
import { Router as ReactRouter } from 'react-router-dom'
3+
import { createBrowserHistory } from 'history'
34

45
interface Props {
56
children: React.ReactElement
@@ -13,8 +14,10 @@ if (RIPROXYPATH !== '') {
1314
MOUNT_PATH = RIPROXYPATH
1415
}
1516

17+
export const history = createBrowserHistory({ basename: MOUNT_PATH })
18+
1619
const Router = ({ children }: Props) => (
17-
<BrowserRouter basename={MOUNT_PATH}>{children}</BrowserRouter>
20+
<ReactRouter history={history}>{children}</ReactRouter>
1821
)
1922

2023
export default Router

redisinsight/ui/src/slices/store.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { createBrowserHistory } from 'history'
21
import { configureStore, combineReducers } from '@reduxjs/toolkit'
32

43
import { getConfig } from 'uiSrc/config'
@@ -59,8 +58,6 @@ import tagsReducer from './instances/tags'
5958

6059
const riConfig = getConfig()
6160

62-
export const history = createBrowserHistory()
63-
6461
export const rootReducer = combineReducers({
6562
app: combineReducers({
6663
info: appInfoReducer,
@@ -149,7 +146,9 @@ const store = configureStore({
149146
devTools: riConfig.app.env !== 'production',
150147
})
151148

152-
export { store }
149+
const dispatch = store.dispatch
150+
151+
export { store, dispatch }
153152

154153
export type ReduxStore = typeof store
155154
export type RootState = ReturnType<typeof rootReducer>

redisinsight/ui/src/utils/test-store.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
1-
import { createBrowserHistory } from 'history'
2-
31
import type { ReduxStore } from 'uiSrc/slices/store'
42

53
// Re-export all types and exports from the real store to avoid circular dependencies during tests
64

75
export type { RootState, AppDispatch, ReduxStore } from 'uiSrc/slices/store'
8-
export const history = createBrowserHistory()
96

107
// Lazy reference to avoid circular dependencies
118
// The store will be set by the store module itself after it's created

0 commit comments

Comments
 (0)