mirror of
https://github.com/zebrajr/react.git
synced 2025-12-07 12:20:38 +01:00
This is the first of a series of PRs, that let you pass functions, by reference, to the client and back. E.g. through Server Context. It's like client references but they're opaque on the client and resolved on the server. To do this, for security, you must opt-in to exposing these functions to the client using the `"use server"` directive. The `"use client"` directive lets you enter the client from the server. The `"use server"` directive lets you enter the server from the client. This works by tagging those functions as Server References. We could potentially expand this to other non-serializable or stateful objects too like classes. This only implements server->server CJS imports and server->server ESM imports. We really should add a loader to the webpack plug-in for client->server imports too. I'll leave closures as an exercise for integrators. You can't "call" a client reference on the server, however, you can "call" a server reference on the client. This invokes a callback on the Flight client options called `callServer`. This lets a router implement calling back to the server. Effectively creating an RPC. This is using JSON for serializing those arguments but more utils coming from client->server serialization. |
||
|---|---|---|
| .. | ||
| config | ||
| createFlowConfigs.js | ||
| environment.js | ||
| react-devtools.js | ||
| react-native-host-hooks.js | ||
| react-relay-hooks.js | ||
| runFlow.js | ||
| xplat.js | ||