TanStackT
TanStack3y ago
3 replies
skinny-azure

How to look for route changes in beta-68

I have this code here:
const rootRoute = new RootRoute({
    component: () => <App />,
})

const indexRoute = new Route({
    getParentRoute: () => rootRoute,
    path: ROUTES.ROOT,
    component: Project,
})

const projectRoute = new Route({
    getParentRoute: () => rootRoute,
    path: ROUTES.PROJECTS,
    component: Project,
})

const processingRoute = new Route({
    getParentRoute: () => rootRoute,
    path: ROUTES.PROCESSING,
    component: Processing,
})

const userProfileRoute = new Route({
    getParentRoute: () => rootRoute,
    path: '/profile/$page',
    component: Profile,
    parseParams: ({ page }) => ({
        page: Number(page) ?? 1,
    }),
    stringifyParams: ({ page }) => ({
        page: `${page}`,
    }),
})

const resourcesRoute = new Route({
    getParentRoute: () => rootRoute,
    path: ROUTES.RESOURCES,
    component: Resources,
    parseParams: ({ page }) => ({
        page: Number(page) ?? 1,
    }),
    stringifyParams: ({ page }) => ({
        page: `${page}`,
    }),
})

const routeTree = rootRoute.addChildren([indexRoute, projectRoute, processingRoute, userProfileRoute, resourcesRoute])

const history = createHashHistory()
const router = new ReactRouter({ routeTree, history })

I'm upgrading from version beta-38 to beta-68, and now not able to use router.subscribe anymore.

Also, on the first startup the app screen is blank, rootTree is not taking the indexRoute by default.
Was this page helpful?