Merge pull request #32913 from screendriver/use-set-interval

[use-set-interval] Add types
This commit is contained in:
Mine Starks
2019-02-12 15:50:18 -08:00
committed by GitHub
4 changed files with 41 additions and 0 deletions
+12
View File
@@ -0,0 +1,12 @@
// Type definitions for use-set-interval 1.0
// Project: https://reacthooks.org/use-set-interval
// Definitions by: Christian Rackerseder <https://github.com/screendriver>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.8
/**
* A React Hook (using useEffect) which uses window.setInterval().
* @param fn a function to execute
* @param delay the delay between executions in milliseconds
*/
export default function useSetInterval(fn: () => void, delay: number): void;
+23
View File
@@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"use-set-interval-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }
@@ -0,0 +1,5 @@
import { useState } from 'react';
import useSetInterval from 'use-set-interval';
const [ count, setCount ] = useState(0);
useSetInterval(() => setCount(count + 1), 1000);