0
Fork 0
mirror of https://github.com/TanStack/router.git synced 2026-11-16 19:38:07 +00:00
router/packages/react-router/tests
Zac Rosenbauer f0138f80b0
feat(react-router): Export ClientOnly (#3969)
Exposes the `ClientOnly` component for preventing rendering & hydration
errors.

## Background

When you attempt to prevent content from rendering using something like
`typeof document !== 'undefined'` as that type of conditional will cause
hydration errors.

## API

```tsx
import { ClientOnly, createRoute } from '@tanstack/react-router'
import { Charts, FallbackCharts } from './charts-that-break-server-side-rendering'

const Route = createRoute({
  // ... other route options
  path: '/dashboard',
  component: Dashboard,
})

function Dashboard() {
  return (
    <div>
      <p>Dashboard</p>
      <ClientOnly fallback={<FallbackCharts />}>
        <Charts />
      </ClientOnly>
    </div>
  )
}
```

> [!NOTE]
> This component as is (other than I removed the `children` as a
`function`) in production on [joggr.io](https://joggr.io)

---------

Co-authored-by: Sean Cassiere <33615041+SeanCassiere@users.noreply.github.com>
Co-authored-by: Ahmed Abdelbaset <A7med3bdulBaset@gmail.com>
Co-authored-by: Birk Skyum <birk.skyum@pm.me>
History 2025-04-13 10:50:44 +02:00
..
lazy test: Add test cases for route id consistency (#2401) 2024-10-15 21:35:04 +02:00
blocker.test.tsx chore: replace <React.Fragment> by <> (#3672) 2025-03-07 00:30:35 +01:00
ClientOnly.test.tsx feat(react-router): Export ClientOnly (#3969) 2025-04-13 10:50:44 +02:00
createLazyRoute.test.tsx test(react-router): correct usage of act and waitFor (#1986) 2024-07-19 10:42:40 +12:00
errorComponent.test.tsx fix(react-router): when ongoing beforeLoad failed, retry next time (#2949) 2024-12-08 19:13:46 +01:00
fileRoute.test-d.tsx refactor(router-core): begin migrating types from react-router and solid-router to router-core (#3538) 2025-02-23 23:18:16 +01:00
fileRoute.test.ts refactor(router-core): move AnyRoute and AnyRouter to router-core (#3640) 2025-03-04 21:48:58 +01:00
index.test.tsx test(react-router): move the SSR redirect tests to the correct test file (#2039) 2024-07-27 20:50:48 +12:00
link.bench.tsx feat(react-router): add remountDeps (#3269) 2025-01-29 01:03:33 +01:00
link.test-d.tsx fix(react-router): use intersections for search param merging (#3220) 2025-01-25 22:44:29 +01:00
link.test.tsx chore: update zod and arktype (#3178) 2025-01-15 23:17:28 +01:00
loaders.test.tsx fix(react-router): improve types for parentMatchPromise (#2669) 2024-10-29 18:52:57 +01:00
Matches.test-d.tsx fix: make to required if from is not set (#3099) 2025-01-04 18:48:57 +01:00
Matches.test.tsx chore: lint (#2369) 2024-09-19 00:28:18 +02:00
navigate.test.tsx fix: allow relative navigate without from (#3654) 2025-03-04 10:11:48 +01:00
redirect.test.tsx chore(deps): update all non-major dependencies (#3018) 2025-01-25 17:52:11 +01:00
redirects.test-d.tsx fix: make to required if from is not set (#3099) 2025-01-04 18:48:57 +01:00
route.test-d.tsx refactor(router-core): migrate matches and route options to core (#3552) 2025-02-24 23:17:58 +01:00
route.test.tsx chore: replace <React.Fragment> by <> (#3672) 2025-03-07 00:30:35 +01:00
routeApi.test-d.tsx feat(react-router): add support for structural sharing for finegrained selectors (#2647) 2024-11-09 22:41:12 +01:00
routeContext.test.tsx fix(react-router): ensure updated context in beforeLoad when returning same properties (#3095) 2025-01-01 13:24:51 +01:00
router.test-d.tsx refactor(router-core): move AnyRoute and AnyRouter to router-core (#3640) 2025-03-04 21:48:58 +01:00
router.test.tsx fix(router-core): allow %25 in path params (#3419) 2025-02-25 11:13:27 +13:00
RouterProvider.test-d.tsx feat: trailingSlashes option on the type level (#1509) 2024-04-25 20:05:34 +02:00
Scripts.test.tsx tests(react-router): import locally in test 2025-02-18 19:19:27 +01:00
searchMiddleware.test.tsx refactor(router-core): move router-core into a separate package (#3171) 2025-01-26 14:06:35 +13:00
setupTests.tsx chore: add eslint rule for unused imports (#2523) 2024-10-12 22:06:33 +02:00
useBlocker.test-d.tsx feat(react-router): add useCanGoBack (#3017) 2025-01-03 21:09:58 +01:00
useBlocker.test.tsx chore: replace <React.Fragment> by <> (#3672) 2025-03-07 00:30:35 +01:00
useCanGoBack.test.tsx feat(react-router): add useCanGoBack (#3017) 2025-01-03 21:09:58 +01:00
useLoaderData.test-d.tsx fix: only call head() when loaderData is available (#3410) 2025-02-13 13:06:13 -07:00
useLocation.test-d.tsx feat(react-router): add support for structural sharing for finegrained selectors (#2647) 2024-11-09 22:41:12 +01:00
useMatch.test-d.tsx refactor(router-core): migrate matches and route options to core (#3552) 2025-02-24 23:17:58 +01:00
useMatch.test.tsx test(react-router): correct usage of act and waitFor (#1986) 2024-07-19 10:42:40 +12:00
useNavigate.test-d.tsx fix: make to required if from is not set (#3099) 2025-01-04 18:48:57 +01:00
useNavigate.test.tsx chore: replace <React.Fragment> by <> (#3672) 2025-03-07 00:30:35 +01:00
useParams.test-d.tsx feat(react-router): add shouldThrow option to useParams and useSearch (#3368) 2025-02-08 22:36:40 +01:00
useRouteContext.test-d.tsx feat(react-router): add support for structural sharing for finegrained selectors (#2647) 2024-11-09 22:41:12 +01:00
useRouterState.test-d.tsx feat(react-router): add support for structural sharing for finegrained selectors (#2647) 2024-11-09 22:41:12 +01:00
useSearch.test-d.tsx fix: only call head() when loaderData is available (#3410) 2025-02-13 13:06:13 -07:00
utils.ts feat(react-router) add search middleware (#2521) 2024-10-14 20:34:35 +02:00