Skip to content

Commit

Permalink
Docs: Add API docs (#460)
Browse files Browse the repository at this point in the history
* Add API docs

* Update config
  • Loading branch information
hyperNURb committed Dec 21, 2022
1 parent 3d284a6 commit 6f0f747
Show file tree
Hide file tree
Showing 22 changed files with 473 additions and 0 deletions.
11 changes: 11 additions & 0 deletions docs/api/react/Link.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
id: Link
title: Link
---

```tsx


```

**Options**
10 changes: 10 additions & 0 deletions docs/api/react/MatchRoute.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
id: MatchRoute
title: MatchRoute
---

```tsx

```

**Options**
11 changes: 11 additions & 0 deletions docs/api/react/Outlet.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
id: Outlet
title: Outlet
---

```tsx
import { Outlet } from '@tanstack/react-router'

```

**Options**
10 changes: 10 additions & 0 deletions docs/api/react/Prompt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
id: Prompt
title: Prompt
---

```tsx

```

**Options**
10 changes: 10 additions & 0 deletions docs/api/react/Route.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
id: Route
title: Route
---

```tsx

```

**Options**
63 changes: 63 additions & 0 deletions docs/api/react/RouterProvider.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
---
id: RouterProvider
title: RouterProvider
---

Use the `RouterProvider` component to connect and provide a `createReactRouter` to your application:

```tsx
import { RouterProvider, createReactRouter } from '@tanstack/react-router'

const router = new createReactRouter()

function App() {
return <RouterProvider router={router}>...</RouterProvider>
}
```

**Options**
- `router: Router`
- **Required**
- the `createReactRouter` instance to provide
- `history?: BrowserHistory | MemoryHistory | HashHistory`
- **Optional**
- `stringifySearch?: SearchSerializer`
- **Optional**
- `parseSearch?: SearchParser`
- **Optional**
- `filterRoutes?: FilterRoutesFn`
- **Optional**
- `defaultPreload?: false | 'intent'`
- **Optional**
- `defaultPreloadMaxAge?: number`
- **Optional**
- `defaultPreloadGcMaxAge?: number`
- **Optional**
- `defaultPreloadDelay?: number`
- **Optional**
- `defaultComponent?: GetFrameworkGeneric<'Component'>`
- **Optional**
- `defaultErrorComponent?: GetFrameworkGeneric<'ErrorComponent'>`
- **Optional**
- `defaultPendingComponent?: GetFrameworkGeneric<'Component'>`
- **Optional**
- `defaultLoaderMaxAge?: number`
- **Optional**
- `defaultLoaderGcMaxAge?: number`
- **Optional**
- `caseSensitive?: boolean`
- **Optional**
- `routeConfig?: TRouteConfig`
- **Optional**
- `basepath?: string`
- **Optional**
- `useServerData?: boolean`
- **Optional**
- `createRouter?: (router: Router<any, any, any>) => void`
- **Optional**
- `createRoute?: (opts: { route: AnyRoute, router: Router<any, any, any> }) => void`
- **Optional**
- `context?: TRouterContext`
- **Optional**
- `loadComponent?: (component: GetFrameworkGeneric<'Component'>) => Promise<GetFrameworkGeneric<'Component'>`
- **Optional**
19 changes: 19 additions & 0 deletions docs/api/react/createReactRouter.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
id: createReactRouter
title: createReactRouter
---

```tsx
import { createReactRouter } from '@tanstack/react-router'

const router = createReactRouter({

})
```

**Options**
- `options: RouterOptions<TRouteConfig, TRouterContext>`
- **Required**

**Returns**
- `router: Router<TRouteConfig, TAllRouteInfo, TRouterContext>`
17 changes: 17 additions & 0 deletions docs/api/react/createRouteConfig.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
id: createRouteConfig
title: createRouteConfig
---

```tsx
import { createRouteConfig } from '@tanstack/react-router'

const router = createRouteConfig()
```

**Options**
- `options: RouterOptions<TRouteConfig, TRouterContext>`
- **Required**

**Returns**
- `router: Router<TRouteConfig, TAllRouteInfo, TRouterContext>`
20 changes: 20 additions & 0 deletions docs/api/react/lazy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
id: lazy
title: lazy
---

```tsx
import { lazy } from '@tanstack/react-router'

export const expensiveRoute = rootRoute.createRoute({
path: 'expensive',
component: lazy(() => import('./Expensive')),
})
```

**Options**
- `importer: () => Promise<{ default: SyncRouteComponent }>`
- **Required**

**Returns**
- `element: RouteComponent`
17 changes: 17 additions & 0 deletions docs/api/react/useAction.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
id: useAction
title: useAction
---

```tsx
const action = useAction({
from
})
```

**Options**
- `from: TFrom`
- **Required**

**Returns**
- `action: Action<TFromRoute['actionPayload'], TFromRoute['actionResponse']>`
13 changes: 13 additions & 0 deletions docs/api/react/useLinkProps.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
id: useLinkProps
title: useLinkProps
---

```tsx
const linkProps = useLinkProps(options)
```

**Options**

**Returns**
- `linkProps: React.AnchorHTMLAttributes<HTMLAnchorElement>`
23 changes: 23 additions & 0 deletions docs/api/react/useLoaderData.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
id: useLoaderData
title: useLoaderData
---

```tsx
const data = useLoaderData({
from,
strict,
select
})
```

**Options**
- `from: TFrom`
- **Required**
- `strict?: TStrict`
- **Optional**
- `select?: (loaderData: TLoaderData) => TSelected`
- **Optional**

**Returns**
- `data: TStrict extends true ? TSelected : TSelected | undefined`
20 changes: 20 additions & 0 deletions docs/api/react/useMatch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
id: useMatch
title: useMatch
---

```tsx
const match = useMatch({
from,
strict
})
```

**Options**
- `from: TFrom`
- **Required**
- `strict?: TStrict`
- **Optional**

**Returns**
- `match: TStrict extends true ? TRouteMatch : TRouteMatch | undefined`
12 changes: 12 additions & 0 deletions docs/api/react/useMatchRoute.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
id: useMatchRoute
title: useMatchRoute
---

```tsx
const matchRoute = useMatchRoute()
```

**Options**

**Returns**
16 changes: 16 additions & 0 deletions docs/api/react/useNavigate.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
id: useNavigate
title: useNavigate
---

```tsx
const navigate = useNavigate({
from
})
```

**Options**
- `from?: TDefaultFrom`
- **Optional**

**Returns**
20 changes: 20 additions & 0 deletions docs/api/react/useParams.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
id: useParams
title: useParams
---

```tsx
const params = useParams({
from,
select
})
```

**Options**
- `from: TFrom`
- **Required**
- `select?: (search: TDefaultSelected) => TSelected`
- **Optional**

**Returns**
- `params: TSelected`
14 changes: 14 additions & 0 deletions docs/api/react/usePrompt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
id: usePrompt
title: usePrompt
---

```tsx
usePrompt(message, when)
```

**Options**
- `message: string`
- **Required**
- `when: boolean | any`
- **Required**
15 changes: 15 additions & 0 deletions docs/api/react/useRoute.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
id: useRoute
title: useRoute
---

```tsx
const route = useRoute(routeId)
```

**Options**
- `routeId: TId`
- **Required**

**Returns**
- `route: Route<RegisteredAllRouteInfo, RegisteredAllRouteInfo['routeInfoById'][TId]>`
11 changes: 11 additions & 0 deletions docs/api/react/useRouter.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
id: useRouter
title: useRouter
---

```tsx
const router = useRouter()
```

**Returns**
- `router: RegisteredRouter`
18 changes: 18 additions & 0 deletions docs/api/react/useRouterStore.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
id: useRouterStore
title: useRouterStore
---

```tsx
const routerStore = useRouterStore({
selector
})
```

**Options**
- `selector?: (state: Router['store']) => T`
- **Optional**

**Returns**
- `routerStore?`
- **Optional**
23 changes: 23 additions & 0 deletions docs/api/react/useSearch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
id: useSearch
title: useSearch
---

```tsx
const search = useSearch({
from,
strict,
select
})
```

**Options**
- `from: TFrom`
- **Required**
- `strict?: TStrict`
- **Optional**
- `select?: (search: TSearch) => TSelected`
- **Optional**

**Returns**
- `search: TSelected | undefined`
Loading

0 comments on commit 6f0f747

Please sign in to comment.