MCPcopy
hub / github.com/facebook/react / encodeFormData

Function encodeFormData

packages/react-client/src/ReactFlightReplyClient.js:910–941  ·  packages/react-client/src/ReactFlightReplyClient.js::encodeFormData
(reference: any)

Source from the content-addressed store, hash-verified

908> = new WeakMap();
909
910function encodeFormData(reference: any): Thenable<FormData> {
911 let resolve, reject;
912 class="cm">// We need to have a handle on the thenable so that we can synchronously set
913 class="cm">// its status from processReply, when it can complete synchronously.
914 const thenable: Thenable<FormData> = new Promise((res, rej) => {
915 resolve = res;
916 reject = rej;
917 });
918 processReply(
919 reference,
920 class="st">'',
921 undefined, class="cm">// TODO: This means React Elements can't be used as state in progressive enhancement.
922 (body: string | FormData) => {
923 if (typeof body === class="st">'string') {
924 const data = new FormData();
925 data.append(class="st">'0', body);
926 body = data;
927 }
928 const fulfilled: FulfilledThenable<FormData> = (thenable: any);
929 fulfilled.status = class="st">'fulfilled';
930 fulfilled.value = body;
931 resolve(body);
932 },
933 e => {
934 const rejected: RejectedThenable<FormData> = (thenable: any);
935 rejected.status = class="st">'rejected';
936 rejected.reason = e;
937 reject(e);
938 },
939 );
940 return thenable;
941}
942
943function defaultEncodeFormAction(
944 this: any => Promise<any>,

Callers 1

defaultEncodeFormActionFunction · 0.85

Calls 4

processReplyFunction · 0.85
appendMethod · 0.80
rejectFunction · 0.70
resolveFunction · 0.50

Tested by

no test coverage detected