mirror of
https://github.com/bendtherules/some-hooks.git
synced 2026-08-19 00:34:17 +00:00
init create-react-hook@2.6.18
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
import * as React from 'react';
|
||||
|
||||
export const useMyHook = () => {
|
||||
let [{
|
||||
counter
|
||||
}, setState] = React.useState<{
|
||||
counter: number;
|
||||
}>({
|
||||
counter: 0
|
||||
});
|
||||
|
||||
React.useEffect(() => {
|
||||
let interval = window.setInterval(() => {
|
||||
counter++;
|
||||
setState({counter})
|
||||
}, 1000)
|
||||
return () => {
|
||||
window.clearInterval(interval);
|
||||
};
|
||||
}, []);
|
||||
|
||||
return counter;
|
||||
};
|
||||
Reference in New Issue
Block a user