TanStackT
TanStack2y ago
7 replies
sad-indigo

Route files keep resetting

Hi Guys,

We've recently started using Tanstack Router in our new project, however there is this really annoying thing that keeps happening.
Sometimes when renaming a file, the contents of the file get reset to the default route file template.

This is how we define our pages:

import {createFileRoute} from '@tanstack/react-router'
import {PageHeader} from "@/components/PageHeader.tsx";
import {useSuspenseQuery} from "@tanstack/react-query";
import {Fab, List, MenuItem, Paper} from "@mui/material";
import {getProjects} from "@/api/queryOptions.ts";
import {HeroLink} from "@/components/HeroLink.tsx";
import {FilterList} from "@mui/icons-material";
import {useAppLayout} from "@/hooks/useAppLayout.tsx";

export const Route = createFileRoute('/_authenticated/projects')({
    component: Projects
})

function Projects() {
    const {data: projects} = useSuspenseQuery(getProjects());

    const {bottomNavigationHeight} = useAppLayout();

    return (
        <>
            <PageHeader title="Projects" />

            <Paper>
                <List>
                    {projects.map(p => (<MenuItem key={p.id} component={HeroLink} to={'/projects/$projectId'} params={{projectId: p.id}}>{p.projectName}</MenuItem>))}
                </List>
            </Paper>

            <Fab
                sx={{
                    position: 'fixed',
                    bottom: bottomNavigationHeight + 16,
                    right: 16
                }} color="primary"
            >
                <FilterList />
            </Fab>
        </>
    )

}


Our development environment:
IDE: Webstorm 2024.1.4
Node version: 20.11.0
React/TS + Vite SWC
Latest version of Tanstack router

Any help would be greatly appreciated.
Was this page helpful?