-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2216 from reduxjs/migrate-to-react-19
Migrate to React 19 (take 2)
- Loading branch information
Showing
13 changed files
with
384 additions
and
350 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
// Copied directly from: | ||
// https://github.com/mridgway/hoist-non-react-statics/blob/main/src/index.js | ||
// https://unpkg.com/browse/@types/[email protected].1/index.d.ts | ||
// https://unpkg.com/browse/@types/[email protected].6/index.d.ts | ||
|
||
/** | ||
* Copyright 2015, Yahoo! Inc. | ||
* Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. | ||
*/ | ||
import type * as React from 'react' | ||
import type { ForwardRefExoticComponent, MemoExoticComponent } from 'react' | ||
import { ForwardRef, Memo, isMemo } from '../utils/react-is' | ||
|
||
const REACT_STATICS = { | ||
|
@@ -66,19 +66,19 @@ function getStatics(component: any) { | |
} | ||
|
||
export type NonReactStatics< | ||
S extends React.ComponentType<any>, | ||
Source, | ||
C extends { | ||
[key: string]: true | ||
} = {}, | ||
> = { | ||
[key in Exclude< | ||
keyof S, | ||
S extends React.MemoExoticComponent<any> | ||
keyof Source, | ||
Source extends MemoExoticComponent<any> | ||
? keyof typeof MEMO_STATICS | keyof C | ||
: S extends React.ForwardRefExoticComponent<any> | ||
: Source extends ForwardRefExoticComponent<any> | ||
? keyof typeof FORWARD_REF_STATICS | keyof C | ||
: keyof typeof REACT_STATICS | keyof typeof KNOWN_STATICS | keyof C | ||
>]: S[key] | ||
>]: Source[key] | ||
} | ||
|
||
const defineProperty = Object.defineProperty | ||
|
@@ -89,12 +89,15 @@ const getPrototypeOf = Object.getPrototypeOf | |
const objectPrototype = Object.prototype | ||
|
||
export default function hoistNonReactStatics< | ||
T extends React.ComponentType<any>, | ||
S extends React.ComponentType<any>, | ||
C extends { | ||
Target, | ||
Source, | ||
CustomStatic extends { | ||
[key: string]: true | ||
} = {}, | ||
>(targetComponent: T, sourceComponent: S): T & NonReactStatics<S, C> { | ||
>( | ||
targetComponent: Target, | ||
sourceComponent: Source, | ||
): Target & NonReactStatics<Source, CustomStatic> { | ||
if (typeof sourceComponent !== 'string') { | ||
// don't hoist over string (html) components | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.