@@ -42,7 +42,7 @@ import { fileDialog } from "file-select-dialog";
42
42
import { useEffect , useMemo , useState , type ReactNode } from "react" ;
43
43
import { useCookies } from "react-cookie" ;
44
44
import "react-reflex/styles.css" ;
45
- import { useHistory , useLocation } from "react-router-dom " ;
45
+ import { useNavigate , useLocation } from "@tanstack/ react-router" ;
46
46
import sjcl from "sjcl" ;
47
47
import { useKeyboardShortcuts } from "use-keyboard-shortcuts" ;
48
48
import DISCORD from "../assets/discord.svg?react" ;
@@ -385,7 +385,7 @@ export function ThemedAppView(props: { datastore: DataStore }) {
385
385
386
386
const classes = useStyles ( { prefersDarkMode : prefersDarkMode } ) ;
387
387
const location = useLocation ( ) ;
388
- const history = useHistory ( ) ;
388
+ const navigate = useNavigate ( ) ;
389
389
390
390
const datastore = props . datastore ;
391
391
@@ -424,13 +424,14 @@ export function ThemedAppView(props: { datastore: DataStore }) {
424
424
] ) ;
425
425
426
426
// Effect: If the user lands on the `/` route, redirect them to the schema editor.
427
+ // TODO: this should probably be a redirect at the routing layer.
427
428
useEffect ( ( ) => {
428
429
( async ( ) => {
429
430
if ( currentItem === undefined ) {
430
- history . replace ( DataStorePaths . Schema ( ) ) ;
431
+ navigate ( { to : DataStorePaths . Schema ( ) , replace : true } ) ;
431
432
}
432
433
} ) ( ) ;
433
- } , [ datastore , currentItem , history ] ) ;
434
+ } , [ datastore , currentItem , navigate ] ) ;
434
435
435
436
const conductDownload = ( ) => {
436
437
const yamlContents = createValidationYAML ( datastore ) ;
@@ -468,7 +469,7 @@ export function ThemedAppView(props: { datastore: DataStore }) {
468
469
datastore . loadFromParsed ( uploaded ) ;
469
470
datastoreUpdated ( ) ;
470
471
471
- history . replace ( DataStorePaths . Schema ( ) ) ;
472
+ navigate ( { to : DataStorePaths . Schema ( ) , replace : true } ) ;
472
473
}
473
474
} ) ( ) ;
474
475
} ;
@@ -563,7 +564,7 @@ export function ThemedAppView(props: { datastore: DataStore }) {
563
564
datastoreUpdated ( ) ;
564
565
565
566
services . liveCheckService . clear ( ) ;
566
- history . replace ( DataStorePaths . Schema ( ) ) ;
567
+ navigate ( { to : DataStorePaths . Schema ( ) , replace : true } ) ;
567
568
} ;
568
569
569
570
const [ previousValidationForDiff , setPreviousValidationForDiff ] = useState <
@@ -639,23 +640,24 @@ export function ThemedAppView(props: { datastore: DataStore }) {
639
640
const validationState = validationService . state ;
640
641
641
642
const handleChangeTab = (
643
+ // TODO: this should be a Link
642
644
_event : React . ChangeEvent < object > ,
643
645
selectedTabValue : string ,
644
646
) => {
645
647
const item = datastore . getById ( selectedTabValue ) ! ;
646
- history . push ( item . pathname ) ;
648
+ navigate ( { to : item . pathname } ) ;
647
649
} ;
648
650
649
651
const setDismissTour = ( ) => {
650
652
setShowTour ( false ) ;
651
653
setCookie ( "dismiss-tour" , true ) ;
652
- history . push ( DataStorePaths . Schema ( ) ) ;
654
+ navigate ( { to : DataStorePaths . Schema ( ) } ) ;
653
655
} ;
654
656
655
657
const handleTourBeforeStep = ( selector : string ) => {
656
658
// Activate the Assertions tab before the assertions dialogs
657
659
if ( selector . includes ( TourElementClass . assert ) ) {
658
- history . push ( DataStorePaths . Assertions ( ) ) ;
660
+ navigate ( { to : DataStorePaths . Assertions ( ) } ) ;
659
661
}
660
662
} ;
661
663
0 commit comments