@@ -42,7 +42,7 @@ import { fileDialog } from "file-select-dialog";
4242import { useEffect , useMemo , useState , type ReactNode } from "react" ;
4343import { useCookies } from "react-cookie" ;
4444import "react-reflex/styles.css" ;
45- import { useHistory , useLocation } from "react-router-dom " ;
45+ import { useNavigate , useLocation } from "@tanstack/ react-router" ;
4646import sjcl from "sjcl" ;
4747import { useKeyboardShortcuts } from "use-keyboard-shortcuts" ;
4848import DISCORD from "../assets/discord.svg?react" ;
@@ -385,7 +385,7 @@ export function ThemedAppView(props: { datastore: DataStore }) {
385385
386386 const classes = useStyles ( { prefersDarkMode : prefersDarkMode } ) ;
387387 const location = useLocation ( ) ;
388- const history = useHistory ( ) ;
388+ const navigate = useNavigate ( ) ;
389389
390390 const datastore = props . datastore ;
391391
@@ -424,13 +424,14 @@ export function ThemedAppView(props: { datastore: DataStore }) {
424424 ] ) ;
425425
426426 // 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.
427428 useEffect ( ( ) => {
428429 ( async ( ) => {
429430 if ( currentItem === undefined ) {
430- history . replace ( DataStorePaths . Schema ( ) ) ;
431+ navigate ( { to : DataStorePaths . Schema ( ) , replace : true } ) ;
431432 }
432433 } ) ( ) ;
433- } , [ datastore , currentItem , history ] ) ;
434+ } , [ datastore , currentItem , navigate ] ) ;
434435
435436 const conductDownload = ( ) => {
436437 const yamlContents = createValidationYAML ( datastore ) ;
@@ -468,7 +469,7 @@ export function ThemedAppView(props: { datastore: DataStore }) {
468469 datastore . loadFromParsed ( uploaded ) ;
469470 datastoreUpdated ( ) ;
470471
471- history . replace ( DataStorePaths . Schema ( ) ) ;
472+ navigate ( { to : DataStorePaths . Schema ( ) , replace : true } ) ;
472473 }
473474 } ) ( ) ;
474475 } ;
@@ -563,7 +564,7 @@ export function ThemedAppView(props: { datastore: DataStore }) {
563564 datastoreUpdated ( ) ;
564565
565566 services . liveCheckService . clear ( ) ;
566- history . replace ( DataStorePaths . Schema ( ) ) ;
567+ navigate ( { to : DataStorePaths . Schema ( ) , replace : true } ) ;
567568 } ;
568569
569570 const [ previousValidationForDiff , setPreviousValidationForDiff ] = useState <
@@ -639,23 +640,24 @@ export function ThemedAppView(props: { datastore: DataStore }) {
639640 const validationState = validationService . state ;
640641
641642 const handleChangeTab = (
643+ // TODO: this should be a Link
642644 _event : React . ChangeEvent < object > ,
643645 selectedTabValue : string ,
644646 ) => {
645647 const item = datastore . getById ( selectedTabValue ) ! ;
646- history . push ( item . pathname ) ;
648+ navigate ( { to : item . pathname } ) ;
647649 } ;
648650
649651 const setDismissTour = ( ) => {
650652 setShowTour ( false ) ;
651653 setCookie ( "dismiss-tour" , true ) ;
652- history . push ( DataStorePaths . Schema ( ) ) ;
654+ navigate ( { to : DataStorePaths . Schema ( ) } ) ;
653655 } ;
654656
655657 const handleTourBeforeStep = ( selector : string ) => {
656658 // Activate the Assertions tab before the assertions dialogs
657659 if ( selector . includes ( TourElementClass . assert ) ) {
658- history . push ( DataStorePaths . Assertions ( ) ) ;
660+ navigate ( { to : DataStorePaths . Assertions ( ) } ) ;
659661 }
660662 } ;
661663
0 commit comments