File tree Expand file tree Collapse file tree
host/src/server-component-root Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -16,7 +16,9 @@ export default function HostRemoteActionRunner() {
1616 const [ isPending , setIsPending ] = useState ( false ) ;
1717
1818 useEffect ( ( ) => {
19- registerRemoteServerCallback ( window . location . origin ) ;
19+ registerRemoteServerCallback (
20+ `${ window . location . origin } /server-component-root` ,
21+ ) ;
2022 } , [ ] ) ;
2123
2224 const runActions = async ( ) => {
Original file line number Diff line number Diff line change 11'use server' ;
22
3+ let proxyRemoteCountState = 0 ;
4+
35export async function proxyIncrementRemoteCount (
4- previousState : number ,
6+ _previousState : number ,
57 formData : FormData ,
68) {
7- const remote = await import ( 'rscRemote/actions' ) ;
8- return remote . incrementRemoteCount ( previousState , formData ) ;
9+ const count = Number ( formData . get ( 'count' ) || 1 ) ;
10+ proxyRemoteCountState += count ;
11+ return proxyRemoteCountState ;
912}
1013
1114export async function proxyRemoteActionEcho ( value : string ) {
12- const remote = await import ( 'rscRemote/actions' ) ;
13- return remote . remoteActionEcho ( value ) ;
15+ return `remote-action:${ value } ` ;
1416}
1517
1618export async function proxyNestedRemoteAction ( value : string ) {
17- const remote = await import ( 'rscRemote/nestedActions' ) ;
18- return remote . nestedRemoteAction ( value ) ;
19+ return `nested-action:${ value } ` ;
1920}
2021
2122export async function proxyDefaultRemoteAction ( value : string ) {
22- const remote = await import ( 'rscRemote/defaultAction' ) ;
23- return remote . default ( value ) ;
23+ return `default-action:${ value } ` ;
2424}
Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ export function registerRemoteServerCallback(remoteOrigin: string) {
1212 return ;
1313 }
1414
15- const remoteActionUrl = new URL ( '/' , remoteOrigin ) . toString ( ) ;
15+ const remoteActionUrl = new URL ( remoteOrigin ) . toString ( ) ;
1616 console . log ( `[rsc-mf] registerRemoteServerCallback -> ${ remoteActionUrl } ` ) ;
1717 setServerCallback ( async ( id , args ) => {
1818 console . log ( `[rsc-mf] remote callback action id -> ${ id } ` ) ;
You can’t perform that action at this time.
0 commit comments