Skip to content

Instantly share code, notes, and snippets.

@rhmoller
Last active October 26, 2018 00:24
Show Gist options
  • Save rhmoller/9240ae80ffc3ef1e29e1ac45edd795f4 to your computer and use it in GitHub Desktop.
Save rhmoller/9240ae80ffc3ef1e29e1ac45edd795f4 to your computer and use it in GitHub Desktop.
Module augmentation for @types/react that adds defintions of some of the new hooks in React 16.7.0-alpha.0
import React from "react";
import {Context, RefObject} from "react";
declare module "react" {
function useState<T>(initialState?: T): [T, (value: T) => void];
function useEffect(effect: () => (() => void) | void, dependencies?: Array<any>): void;
function useContext<C>(context: Context<C>): C;
function useReducer<S>(reducer: (state: S, action: any) => S, initialState?: S, initialAction?: any): [S, (args: any) => void];
function useCallback(callback: () => void, dependencies?: Array<any>): () => void;
function useMemo<R>(fn: () => R, dependencies?: Array<any>): R;
function useRef<T>(initialValue: T | null): RefObject<T>;
}
@rhmoller
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment