Skip to content

Commit

Permalink
[Flight] Fix reference param type in registerServerReference (#27688
Browse files Browse the repository at this point in the history
)

The `reference` that is passed into `registerServerReference` can be a
plain function. It does not need to have the three additonal properties
of a `ServerRefeference`. In fact, adding these properties (plus `bind`)
is precisely what `registerServerReference` does.
  • Loading branch information
unstubbable authored Feb 15, 2024
1 parent 0745e6b commit 9268672
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions packages/react-server-dom-esm/src/ReactFlightESMReferences.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ function bind(this: ServerReference<any>): any {
return newFn;
}

export function registerServerReference<T>(
reference: ServerReference<T>,
export function registerServerReference<T: Function>(
reference: T,
id: string,
exportName: string,
): ServerReference<T> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ function bind(this: ServerReference<any>): any {
return newFn;
}

export function registerServerReference<T>(
reference: ServerReference<T>,
export function registerServerReference<T: Function>(
reference: T,
id: string,
exportName: null | string,
): ServerReference<T> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ function bind(this: ServerReference<any>): any {
return newFn;
}

export function registerServerReference<T>(
reference: ServerReference<T>,
export function registerServerReference<T: Function>(
reference: T,
id: string,
exportName: null | string,
): ServerReference<T> {
Expand Down

0 comments on commit 9268672

Please sign in to comment.