[react-click-outside-hook] add type def for useClickOutside function

This commit is contained in:
Bryan Deloeste
2019-04-11 13:24:06 -07:00
parent f2c704c69a
commit 07fae015dd
4 changed files with 36 additions and 0 deletions

View 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];

View File

@@ -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"));

View 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"]
}

View File

@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }