Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(main-doc): add missing LoaderData export #4882

Merged
merged 2 commits into from
Oct 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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