mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-04-04 20:54:36 +00:00
[react-click-outside-hook] add type def for useClickOutside function
This commit is contained in:
8
types/react-click-outside-hook/index.d.ts
vendored
Normal file
8
types/react-click-outside-hook/index.d.ts
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
// Type definitions for react-click-outside-hook 1.0
|
||||
// Project: https://github.com/bdeloeste/react-click-outside-hook#readme
|
||||
// Definitions by: Bryan Deloeste <https://github.com/bdeloeste>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
import { MutableRefObject } from "react";
|
||||
|
||||
export function useClickOutside<T>(): [MutableRefObject<T>, boolean];
|
||||
@@ -0,0 +1,11 @@
|
||||
import * as React from "react";
|
||||
import { render } from "react-dom";
|
||||
|
||||
import { useClickOutside } from "react-click-outside-hook";
|
||||
|
||||
function Component() {
|
||||
const [ref, hasClickedOutside] = useClickOutside<HTMLDivElement>();
|
||||
return <div ref={ref}>{hasClickedOutside.toString()}</div>;
|
||||
}
|
||||
|
||||
render(<Component />, document.getElementById("test"));
|
||||
16
types/react-click-outside-hook/tsconfig.json
Normal file
16
types/react-click-outside-hook/tsconfig.json
Normal file
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": ["es6", "dom"],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"jsx": "react",
|
||||
"baseUrl": "../",
|
||||
"typeRoots": ["../"],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": ["index.d.ts", "react-click-outside-hook-tests.tsx"]
|
||||
}
|
||||
1
types/react-click-outside-hook/tslint.json
Normal file
1
types/react-click-outside-hook/tslint.json
Normal file
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user