diff --git a/packages/react-server-dom-esm/src/ReactFlightESMReferences.js b/packages/react-server-dom-esm/src/ReactFlightESMReferences.js index 57bbdd121cee8..62c0d2f70cb9e 100644 --- a/packages/react-server-dom-esm/src/ReactFlightESMReferences.js +++ b/packages/react-server-dom-esm/src/ReactFlightESMReferences.js @@ -53,9 +53,12 @@ function bind(this: ServerReference) { if (this.$$typeof === SERVER_REFERENCE_TAG) { // $FlowFixMe[method-unbinding] const args = ArraySlice.call(arguments, 1); - newFn.$$typeof = SERVER_REFERENCE_TAG; - newFn.$$id = this.$$id; - newFn.$$bound = this.$$bound ? this.$$bound.concat(args) : args; + return Object.defineProperties((newFn: any), { + $$typeof: {value: SERVER_REFERENCE_TAG}, + $$id: {value: this.$$id}, + $$bound: {value: this.$$bound ? this.$$bound.concat(args) : args}, + bind: {value: bind}, + }); } return newFn; } diff --git a/packages/react-server-dom-turbopack/src/ReactFlightTurbopackReferences.js b/packages/react-server-dom-turbopack/src/ReactFlightTurbopackReferences.js index 9df0e43bd75e1..4438fc5de3f59 100644 --- a/packages/react-server-dom-turbopack/src/ReactFlightTurbopackReferences.js +++ b/packages/react-server-dom-turbopack/src/ReactFlightTurbopackReferences.js @@ -66,9 +66,12 @@ function bind(this: ServerReference) { const newFn = FunctionBind.apply(this, arguments); if (this.$$typeof === SERVER_REFERENCE_TAG) { const args = ArraySlice.call(arguments, 1); - newFn.$$typeof = SERVER_REFERENCE_TAG; - newFn.$$id = this.$$id; - newFn.$$bound = this.$$bound ? this.$$bound.concat(args) : args; + return Object.defineProperties((newFn: any), { + $$typeof: {value: SERVER_REFERENCE_TAG}, + $$id: {value: this.$$id}, + $$bound: {value: this.$$bound ? this.$$bound.concat(args) : args}, + bind: {value: bind}, + }); } return newFn; } diff --git a/packages/react-server-dom-webpack/src/ReactFlightWebpackReferences.js b/packages/react-server-dom-webpack/src/ReactFlightWebpackReferences.js index 6952dad11134a..059925a3cfa1a 100644 --- a/packages/react-server-dom-webpack/src/ReactFlightWebpackReferences.js +++ b/packages/react-server-dom-webpack/src/ReactFlightWebpackReferences.js @@ -61,14 +61,17 @@ function registerClientReferenceImpl( const FunctionBind = Function.prototype.bind; // $FlowFixMe[method-unbinding] const ArraySlice = Array.prototype.slice; -function bind(this: ServerReference) { +function bind(this: ServerReference): any { // $FlowFixMe[unsupported-syntax] const newFn = FunctionBind.apply(this, arguments); if (this.$$typeof === SERVER_REFERENCE_TAG) { const args = ArraySlice.call(arguments, 1); - newFn.$$typeof = SERVER_REFERENCE_TAG; - newFn.$$id = this.$$id; - newFn.$$bound = this.$$bound ? this.$$bound.concat(args) : args; + return Object.defineProperties((newFn: any), { + $$typeof: {value: SERVER_REFERENCE_TAG}, + $$id: {value: this.$$id}, + $$bound: {value: this.$$bound ? this.$$bound.concat(args) : args}, + bind: {value: bind}, + }); } return newFn; } diff --git a/packages/react-server-dom-webpack/src/__tests__/ReactFlightDOMBrowser-test.js b/packages/react-server-dom-webpack/src/__tests__/ReactFlightDOMBrowser-test.js index cc4f0b5331b72..7a1fa32cd863d 100644 --- a/packages/react-server-dom-webpack/src/__tests__/ReactFlightDOMBrowser-test.js +++ b/packages/react-server-dom-webpack/src/__tests__/ReactFlightDOMBrowser-test.js @@ -1011,7 +1011,7 @@ describe('ReactFlightDOMBrowser', () => { const ClientRef = clientExports(Client); const stream = ReactServerDOMServer.renderToReadableStream( - , + , webpackMap, );