-
Notifications
You must be signed in to change notification settings - Fork 27.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Avoid server action
endpoint
function indirection (#71572)
This PR removes the extra wrapper functions and `.bind()` calls from the action entrypoint loader. Instead, the loader module now only re-exports the actions from the original module using the IDs as export names. This ensures that the same action instance will always remain identical. It also unblocks the combined usage of `"use cache"` and `"use server"` functions. --------- Co-authored-by: Shu Ding <[email protected]>
- Loading branch information
1 parent
45a328a
commit 475bdb1
Showing
6 changed files
with
82 additions
and
31 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
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
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
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
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,13 @@ | ||
'use client' | ||
|
||
export function Client({ foo, b }) { | ||
return ( | ||
<button | ||
onClick={() => { | ||
foo(b) | ||
}} | ||
> | ||
Trigger | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { Client } from './client' | ||
|
||
export default async function Page() { | ||
async function b() { | ||
'use server' | ||
} | ||
|
||
async function foo(a) { | ||
'use server' | ||
console.log('result:', a === b) | ||
} | ||
|
||
return <Client foo={foo} b={b} /> | ||
} |