Skip to content

Commit

Permalink
docs(main-doc): add missing LoaderData export (#4882)
Browse files Browse the repository at this point in the history
Signed-off-by: baizhi958216 <[email protected]>
  • Loading branch information
baizhi958216 authored Oct 31, 2023
1 parent f0a0e78 commit 0bb35da
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/healthy-brooms-travel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@modern-js/main-doc': patch
---

docs(main-doc): 导出 LoaderData 类型 检查代码高亮
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Create `src/routes/page.data.ts`:
```tsx
import { name, internet } from 'faker';

type LoaderData = {
export type LoaderData = {
code: number;
data: {
name: string;
Expand Down Expand Up @@ -56,8 +56,9 @@ Data Loader doesn't just work for SSR. In CSR projects, Data Loader can also avo

Modern.js also provides a hooks API called `useLoaderData`, we modify the exported component of `src/routes/page.tsx`:

```tsx {1,4,13}
```tsx {1,2,5,13}
import { useLoaderData } from '@modern-js/runtime/router';
import type { LoaderData } from './page.data';

function Index() {
const { data } = useLoaderData() as LoaderData;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ pnpm add @types/faker@5 -D
```tsx
import { name, internet } from 'faker';

type LoaderData = {
export type LoaderData = {
code: number;
data: {
name: string;
Expand Down Expand Up @@ -56,8 +56,9 @@ Data Loader 并非只为 SSR 工作。在 CSR 项目中,Data Loader 也可以

Modern.js 也提供了一个叫 `useLoaderData` 的 hooks API,我们修改 `src/routes/page.tsx` 导出的组件:

```tsx {1,4,13}
```tsx {1,2,5,13}
import { useLoaderData } from '@modern-js/runtime/router';
import type { LoaderData } from './page.data';

function Index() {
const { data } = useLoaderData() as LoaderData;
Expand Down

0 comments on commit 0bb35da

Please sign in to comment.