11import { StylesProvider } from "@material-ui/core/styles"
2- import { History } from "history"
32import React , { Component } from "react"
43import ReactOutlineManager from "react-outline-manager"
5- import { useHistory } from "react-router"
6- import { Route , RouteComponentProps , Switch } from "react-router-dom"
4+ import { useLocation , useNavigate , Location } from "react-router-dom "
5+ import { Route , Routes } from "react-router-dom"
76import AnalyticsNudge from "./AnalyticsNudge"
87import AppController from "./AppController"
98import { tiltfileKeyContext } from "./BrowserStorage"
@@ -37,8 +36,9 @@ import {
3736} from "./types"
3837
3938export type HudProps = {
40- history : History
4139 interfaceVersion : InterfaceVersion
40+ navigate : ReturnType < typeof useNavigate >
41+ location : Location
4242}
4343
4444// Snapshot logs are capped to 1MB (max upload size is 4MB; this ensures between the rest of state and JSON overhead
@@ -51,14 +51,16 @@ export default class HUD extends Component<HudProps, HudState> {
5151 // The root of the HUD view, without the slash.
5252 private pathBuilder : PathBuilder
5353 private controller : AppController
54- private history : History
54+ private navigate : ReturnType < typeof useNavigate >
55+ private location : Location
5556
5657 constructor ( props : HudProps ) {
5758 super ( props )
5859
5960 this . pathBuilder = new PathBuilder ( window . location )
6061 this . controller = new AppController ( this . pathBuilder , this )
61- this . history = props . history
62+ this . navigate = props . navigate
63+ this . location = props . location
6264
6365 this . state = {
6466 view : { } ,
@@ -102,7 +104,7 @@ export default class HUD extends Component<HudProps, HudState> {
102104 }
103105
104106 setHistoryLocation ( path : string ) {
105- this . props . history . replace ( path )
107+ this . props . navigate ( path , { replace : true } )
106108 }
107109
108110 path ( relPath : string ) {
@@ -119,7 +121,7 @@ export default class HUD extends Component<HudProps, HudState> {
119121 }
120122 return {
121123 view : view ,
122- path : this . props . history . location . pathname ,
124+ path : this . props . location . pathname ,
123125 snapshotHighlight : state . snapshotHighlight ,
124126 createdAt : new Date ( ) . toISOString ( ) ,
125127 }
@@ -226,27 +228,28 @@ export default class HUD extends Component<HudProps, HudState> {
226228 < ResourceGroupsContextProvider >
227229 < ResourceListOptionsProvider >
228230 < ResourceSelectionProvider >
229- < Switch >
231+ < Routes >
230232 < Route
231233 path = { this . path ( "/r/:name/overview" ) }
232- render = { ( _props : RouteComponentProps < any > ) => (
234+ element = {
233235 < SidebarContextProvider >
234236 < OverviewResourcePane
235237 view = { this . state . view }
236238 isSocketConnected = { isSocketConnected }
237239 />
238240 </ SidebarContextProvider >
239- ) }
241+ }
240242 />
241243 < Route
242- render = { ( ) => (
244+ path = "*"
245+ element = {
243246 < OverviewTablePane
244247 view = { this . state . view }
245248 isSocketConnected = { isSocketConnected }
246249 />
247- ) }
250+ }
248251 />
249- </ Switch >
252+ </ Routes >
250253 </ ResourceSelectionProvider >
251254 </ ResourceListOptionsProvider >
252255 </ ResourceGroupsContextProvider >
@@ -304,12 +307,18 @@ export default class HUD extends Component<HudProps, HudState> {
304307}
305308
306309export function HUDFromContext ( props : React . PropsWithChildren < { } > ) {
307- let history = useHistory ( )
308- let interfaceVersion = useInterfaceVersion ( )
310+ const navigate = useNavigate ( )
311+ const location = useLocation ( )
312+ const interfaceVersion = useInterfaceVersion ( )
313+
309314 return (
310315 /* allow Styled Components to override MUI - https://material-ui.com/guides/interoperability/#controlling-priority-3*/
311316 < StylesProvider injectFirst >
312- < HUD history = { history } interfaceVersion = { interfaceVersion } />
317+ < HUD
318+ interfaceVersion = { interfaceVersion }
319+ navigate = { navigate }
320+ location = { location }
321+ />
313322 </ StylesProvider >
314323 )
315324}
0 commit comments