Last active
March 14, 2022 01:58
-
-
Save xiaoxiangmoe/edc5c1674b0ec273f0be9e2f323f90dc to your computer and use it in GitHub Desktop.
DefinitelyTyped @types/react
This file contains hidden or 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
import * as React from "react"; | |
declare module "react" { | |
function memo<P>( | |
Component:React.SFC<P>, | |
propsAreEqual?:(( | |
prevProps: Readonly<P & { children?: ReactNode }>, | |
nextProps: Readonly<P & { children?: ReactNode }> | |
)=>boolean | |
)):React.SFC<P>; | |
function lazy<T extends () => Promise<{ default: React.ComponentType<any> }>>( | |
importFunction: T, | |
): T extends () => Promise<{ default: React.ComponentType<infer P> }> | |
? React.ComponentType<P> | |
: React.ComponentType; | |
} |
This file contains hidden or 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
import * as React from "react"; | |
declare module "react" { | |
function useState<T>(initialState: T | (() => T)): [T, (newState: T) => void]; | |
function useEffect( | |
create: () => void|Promise<void> | (() => void)|Promise<() => void>, | |
inputs?: ReadonlyArray<unknown> | |
): void; | |
function useContext<T>(foo: React.Context<T>): T; | |
function useReducer<S, A>( | |
reducer: (state: S, action: A) => S, | |
initialState: S | |
): [S, (action: A) => void]; | |
function useCallback<F extends (...args: never[]) => unknown>( | |
callback: F, | |
inputs?: ReadonlyArray<unknown> | |
): F; | |
function useMemo<T>(create: () => T, inputs?: ReadonlyArray<unknown>): T; | |
function useRef<T extends unknown>(initialValue?: T): React.RefObject<T>; | |
function useImperativeMethods<T>( | |
ref: React.Ref<T>, | |
createInstance: () => T, | |
inputs?: ReadonlyArray<unknown> | |
): void; | |
const useMutationEffect: typeof useEffect; | |
const useLayoutEffect: typeof useEffect; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
使用说明:在 src 目录下建立一个 shims 目录,然后把上面的文件丢进去就完事了。