Merged
Conversation
|
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit d5d12c9:
|
dai-shi
commented
Mar 13, 2023
| const response = fetch(`/?${searchParams}`, { | ||
| method: "POST", | ||
| body: JSON.stringify(args), | ||
| body: await encodeReply(args), |
Member
Author
There was a problem hiding this comment.
Not sure if doing this will set content-type header for form data.
Member
Author
|
Did an experiment: diff --git a/examples/04_callserver/src/Counter.tsx b/examples/04_callserver/src/Counter.tsx
index c55c50d..d0dac48 100644
--- a/examples/04_callserver/src/Counter.tsx
+++ b/examples/04_callserver/src/Counter.tsx
@@ -21,6 +21,18 @@ export const Counter = ({
>
greet("client:" + count) = {text}
</button>
+ <button
+ onClick={async () => {
+ const res = await greet(
+ new Promise((resolve) =>
+ setTimeout(() => resolve("from promise"), 1000)
+ )
+ );
+ console.log(res);
+ }}
+ >
+ greet with delay
+ </button>
</p>
<h3>This is a client component.</h3>
</div>
diff --git a/examples/04_callserver/src/funcs.ts b/examples/04_callserver/src/funcs.ts
index 119d09f..d7540fb 100644
--- a/examples/04_callserver/src/funcs.ts
+++ b/examples/04_callserver/src/funcs.ts
@@ -1,3 +1,3 @@
"use server";
-export const greet = (name: string) => `Hello ${name} from server!`;
+export const greet = async (name: string) => `Hello ${await name} from server!`; |
commit: |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



following facebook/react#26360