mirror of
https://github.com/bendtherules/some-hooks.git
synced 2026-08-18 13:52:05 +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;
|
||||
};
|
||||
Vendored
+1
@@ -0,0 +1 @@
|
||||
/// <reference types="react-scripts" />
|
||||
@@ -0,0 +1,7 @@
|
||||
import { useMyHook } from './'
|
||||
|
||||
describe('useMyHook', () => {
|
||||
it('is truthy', () => {
|
||||
expect(useMyHook).toBeTruthy()
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user