-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: test action returning components (#503)
- Loading branch information
Showing
5 changed files
with
79 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
packages/react-server/examples/basic/src/routes/test/action/_action2.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
"use server"; | ||
|
||
import { sleep } from "@hiogawa/utils"; | ||
import React from "react"; | ||
import { TestClientComponent } from "./_client2"; | ||
|
||
export async function actionReturnComponent() { | ||
return ( | ||
<> | ||
<div> | ||
<TestClientComponent /> | ||
</div> | ||
<div className="border px-2"> | ||
[server]{" "} | ||
<React.Suspense fallback={"Loading..."}> | ||
<TestServerComponent /> | ||
</React.Suspense> | ||
</div> | ||
</> | ||
); | ||
} | ||
|
||
async function TestServerComponent() { | ||
await sleep(1000); | ||
return <>OK!</>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
packages/react-server/examples/basic/src/routes/test/action/_client2.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
"use client"; | ||
|
||
import React from "react"; | ||
|
||
export function TestClientComponent() { | ||
const [count, setCount] = React.useState(0); | ||
return ( | ||
<button | ||
className="antd-btn antd-btn-default px-2" | ||
onClick={() => setCount((c) => c + 1)} | ||
> | ||
[client] counter: {count} | ||
</button> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters