-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use offset in ScrollToView Add ESLint and Prettier as dev dependencies Fix ESLint issues
- Loading branch information
1 parent
f91503a
commit 4a63f36
Showing
5 changed files
with
1,425 additions
and
179 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
module.exports = { | ||
root: true, | ||
extends: ['@react-native-community', 'prettier'], | ||
parser: '@typescript-eslint/parser', | ||
plugins: ['@typescript-eslint', 'import'], | ||
rules: { | ||
'arrow-body-style': ['error', 'as-needed'], | ||
'no-console': 'error', | ||
'react/jsx-key': 'error', | ||
'react-hooks/exhaustive-deps': 'off', | ||
'import/order': [ | ||
'error', | ||
{ | ||
groups: ['external', 'internal', 'builtin', 'parent', 'unknown', 'index', 'sibling'], | ||
'newlines-between': 'always', | ||
}, | ||
], | ||
}, | ||
} |
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,25 @@ | ||
import { useRef, useEffect, useCallback } from "react"; | ||
import { useRef, useEffect, useCallback } from 'react' | ||
|
||
const useTimeout = (): [ | ||
(callback: () => void, delay: number) => void, | ||
() => void | ||
] => { | ||
const timer = useRef<number | null>(null); | ||
const useTimeout = (): [(callback: () => void, delay: number) => void, () => void] => { | ||
const timer = useRef<number | null>(null) | ||
|
||
const clearTimer = useCallback(() => { | ||
if (timer.current) { | ||
clearTimeout(timer.current); | ||
clearTimeout(timer.current) | ||
} | ||
}, []); | ||
}, []) | ||
|
||
useEffect(() => clearTimer, []); | ||
useEffect(() => clearTimer, []) | ||
|
||
const setTimer = useCallback((callback: () => void, delay: number) => { | ||
clearTimer(); | ||
clearTimer() | ||
timer.current = setTimeout(() => { | ||
timer.current = null; | ||
callback(); | ||
}, delay); | ||
}, []); | ||
timer.current = null | ||
callback() | ||
}, delay) | ||
}, []) | ||
|
||
return [setTimer, clearTimer]; | ||
}; | ||
return [setTimer, clearTimer] | ||
} | ||
|
||
export default useTimeout; | ||
export default useTimeout |
Oops, something went wrong.