Created
July 18, 2020 14:29
-
-
Save karol-majewski/34a34c7b0e3350b52ab02132e39826b0 to your computer and use it in GitHub Desktop.
Using React Hooks inside class components with TypeScript
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'; | |
import { useIdle } from 'react-use'; | |
interface Props { | |
timeoutMs: number; | |
children: (data: boolean) => React.ReactElement | null; | |
} | |
const IdleStateRecognition: React.FunctionComponent<Props> = ({ children, timeoutMs }) => { | |
const isIdle = useIdle(timeoutMs); | |
return children(isIdle); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage: