Repository: facebook/react
Pull request: Add `referrerPolicy` option to `ReactDOM.preload()`

## Summary

We started using `ReactDOM.preload()` in Next.js but found the `referrerPolicy` option was missing.

- Related https://github.com/vercel/next.js/pull/52425

## How did you test this change?

```
yarn test packages/react-dom/src/__tests__/ReactDOMFloat-test.js
```


Changed files:
filename: packages/react-dom-bindings/src/client/ReactFiberConfigDOM.js
patch: @@ -2284,6 +2284,7 @@ function preloadPropsFromPreloadOptions(
     fetchPriority: options.fetchPriority,
     imageSrcSet: options.imageSrcSet,
     imageSizes: options.imageSizes,
+    referrerPolicy: options.referrerPolicy,
   };
 }
 

filename: packages/react-dom-bindings/src/server/ReactFizzConfigDOM.js
patch: @@ -5564,6 +5564,7 @@ function preloadPropsFromPreloadOptions(
     fetchPriority: options.fetchPriority,
     imageSrcSet: options.imageSrcSet,
     imageSizes: options.imageSizes,
+    referrerPolicy: options.referrerPolicy,
   };
 }
 

filename: packages/react-dom/src/__tests__/ReactDOMFloat-test.js
patch: @@ -3686,6 +3686,91 @@ body {
     );
   });
 
+  it('should handle referrerPolicy on image preload', async () => {
+    function App({isClient}) {
+      ReactDOM.preload('/server', {
+        as: 'image',
+        imageSrcSet: '/server',
+        imageSizes: '100vw',
+        referrerPolicy: 'no-referrer',
+      });
+
+      if (isClient) {
+        ReactDOM.preload('/client', {
+          as: 'image',
+          imageSrcSet: '/client',
+          imageSizes: '100vw',
+          referrerPolicy: 'no-referrer',
+        });
+      }
+
+      return (
+        <html>
+          <body>hello</body>
+        </html>
+      );
+    }
+
+    await act(() => {
+      renderToPipeableStream(<App />).pipe(writable);
+    });
+    expect(getMeaningfulChildren(document)).toEqual(
+      <html>
+        <head>
+          <link
+            rel="preload"
+            as="image"
+            imagesrcset="/server"
+            imagesizes="100vw"
+            referrerpolicy="no-referrer"
+          />
+        </head>
+        <body>hello</body>
+      </html>,
+    );
+
+    const root = ReactDOMClient.hydrateRoot(document, <App />);
+    await waitForAll([]);
+    expect(getMeaningfulChildren(document)).toEqual(
+      <html>
+        <head>
+          <link
+            rel="preload"
+            as="image"
+            imagesrcset="/server"
+            imagesizes="100vw"
+            referrerpolicy="no-referrer"
+          />
+        </head>
+        <body>hello</body>
+      </html>,
+    );
+
+    root.render(<App isClient={true} />);
+    await waitForAll([]);
+    expect(getMeaningfulChildren(document)).toEqual(
+      <html>
+        <head>
+          <link
+            rel="preload"
+            as="image"
+            imagesrcset="/server"
+            imagesizes="100vw"
+            referrerpolicy="no-referrer"
+          />
+          <link
+            rel="preload"
+            as="image"
+            imagesrcset="/client"
+            imagesizes="100vw"
+            referrerpolicy="no-referrer"
+          />
+        </head>
+        <body>hello</body>
+      </html>,
+    );
+  });
+
   describe('ReactDOM.prefetchDNS(href)', () => {
     it('creates a dns-prefetch resource when called', async () => {
       function App({url}) {

filename: packages/react-dom/src/shared/ReactDOMTypes.js
patch: @@ -18,6 +18,7 @@ export type PreloadOptions = {
   fetchPriority?: 'high' | 'low' | 'auto',
   imageSrcSet?: string,
   imageSizes?: string,
+  referrerPolicy?: string,
 };
 export type PreinitOptions = {
   as: string,