Unverified Commit ad6907a8 authored by Joseph's avatar Joseph Committed by GitHub

docs: example are incorrect async function exports only (#85453)

parent 34dd8d42
...@@ -83,14 +83,14 @@ Any non-serializable arguments, props, or closed-over values will turn into refe ...@@ -83,14 +83,14 @@ Any non-serializable arguments, props, or closed-over values will turn into refe
For example, a cached function can take in JSX as a `children` prop and return `<div>{children}</div>`, but it won't be able to introspect the actual `children` object. This allows you to nest uncached content inside a cached component. For example, a cached function can take in JSX as a `children` prop and return `<div>{children}</div>`, but it won't be able to introspect the actual `children` object. This allows you to nest uncached content inside a cached component.
```tsx filename="app/ui/cached-component.tsx" switcher ```tsx filename="app/ui/cached-component.tsx" switcher
function CachedComponent({ children }: { children: ReactNode }) { async function CachedComponent({ children }: { children: ReactNode }) {
'use cache' 'use cache'
return <div>{children}</div> return <div>{children}</div>
} }
``` ```
```jsx filename="app/ui/cached-component.js" switcher ```jsx filename="app/ui/cached-component.js" switcher
function CachedComponent({ children }) { async function CachedComponent({ children }) {
'use cache' 'use cache'
return <div>{children}</div> return <div>{children}</div>
} }
...@@ -136,7 +136,7 @@ To pre-render an entire route, add `use cache` to the top of **both** the `layou ...@@ -136,7 +136,7 @@ To pre-render an entire route, add `use cache` to the top of **both** the `layou
```tsx filename="app/layout.tsx" switcher ```tsx filename="app/layout.tsx" switcher
'use cache' 'use cache'
export default function Layout({ children }: { children: ReactNode }) { export default async function Layout({ children }: { children: ReactNode }) {
return <div>{children}</div> return <div>{children}</div>
} }
``` ```
...@@ -144,7 +144,7 @@ export default function Layout({ children }: { children: ReactNode }) { ...@@ -144,7 +144,7 @@ export default function Layout({ children }: { children: ReactNode }) {
```jsx filename="app/page.tsx" switcher ```jsx filename="app/page.tsx" switcher
'use cache' 'use cache'
export default function Layout({ children }) { export default async function Layout({ children }) {
return <div>{children}</div> return <div>{children}</div>
} }
``` ```
...@@ -159,7 +159,7 @@ async function Users() { ...@@ -159,7 +159,7 @@ async function Users() {
// loop through users // loop through users
} }
export default function Page() { export default async function Page() {
return ( return (
<main> <main>
<Users /> <Users />
...@@ -176,7 +176,7 @@ async function Users() { ...@@ -176,7 +176,7 @@ async function Users() {
// loop through users // loop through users
} }
export default function Page() { export default async function Page() {
return ( return (
<main> <main>
<Users /> <Users />
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment