diff --git a/.eslintrc.js b/.eslintrc.js
index 4eb8573..4ac1044 100644
--- a/.eslintrc.js
+++ b/.eslintrc.js
@@ -23,7 +23,8 @@ module.exports = {
'import/no-unresolved': 'error',
'no-duplicate-imports': 'error',
'jsx-a11y/click-events-have-key-events': 'off',
- 'react-hooks/rules-of-hooks': 'error'
+ 'react-hooks/rules-of-hooks': 'error',
+ 'react-hooks/reactive-deps': 'error'
},
settings: {
react: {
diff --git a/README.md b/README.md
index b7c41f0..1840f9b 100644
--- a/README.md
+++ b/README.md
@@ -111,5 +111,5 @@ Thanks goes out to all these wonderful people ([emoji key](https://github.com/ke
-
+
diff --git a/components/RandomImage.js b/components/RandomImage.js
index 2c6ed06..214d9cd 100644
--- a/components/RandomImage.js
+++ b/components/RandomImage.js
@@ -42,13 +42,13 @@ function RandomImage(props) {
if (cacheIndex === 0 || cacheIndex > cache.length - 2) {
updateCache()
}
- }, [cacheIndex])
+ }, [cacheIndex, cache.length, updateCache])
React.useEffect(() => {
if (imgs) {
cache.push(...imgs)
}
- }, [imgs])
+ }, [cache, imgs])
const loading = updating || selecting
diff --git a/components/TweetButton.js b/components/TweetButton.js
index 12d4851..437f7d6 100644
--- a/components/TweetButton.js
+++ b/components/TweetButton.js
@@ -4,10 +4,12 @@ import { useAsyncCallback } from '@dawnlabs/tacklebox'
import Button from './Button'
function useWindowListener(key, fn) {
+ const callback = React.useRef(fn)
+
React.useEffect(() => {
- window.addEventListener(key, fn)
- return () => window.removeEventListener(key, fn)
- }, [])
+ window.addEventListener(key, callback.current)
+ return () => window.removeEventListener(key, callback.current)
+ }, [key, callback])
}
function useOnlineListener() {
@@ -19,7 +21,7 @@ function useOnlineListener() {
? navigator.onLine
: true
)
- }, [])
+ }, [setOnline])
useWindowListener('offline', () => setOnline(false))
useWindowListener('online', () => setOnline(true))
diff --git a/package.json b/package.json
index 9de61cf..143ad55 100644
--- a/package.json
+++ b/package.json
@@ -60,7 +60,7 @@
"eslint-plugin-import": "^2.16.0",
"eslint-plugin-jsx-a11y": "^6.2.1",
"eslint-plugin-react": "^7.12.3",
- "eslint-plugin-react-hooks": "^1.0.1",
+ "eslint-plugin-react-hooks": "^1.1.0-alpha.1",
"husky": "^1.3.1",
"lint-staged": "^8.1.3",
"now": "^14.0.0",
diff --git a/yarn.lock b/yarn.lock
index fdf4013..6d90584 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -2755,10 +2755,10 @@ eslint-plugin-jsx-a11y@^6.2.1:
has "^1.0.3"
jsx-ast-utils "^2.0.1"
-eslint-plugin-react-hooks@^1.0.1:
- version "1.0.1"
- resolved "https://registry.yarnpkg.com/eslint-plugin-react-hooks/-/eslint-plugin-react-hooks-1.0.1.tgz#76b6fb4edafab02eab0090078977687157605dd9"
- integrity sha512-yNhvY7EFBp0mq0Bt8BHoS57GwJ4e1qSYdvDFSfPnjmiSmyGUfQFQGcQs4K0JQFDGopWkURWq58psbUJIhWZ2Kg==
+eslint-plugin-react-hooks@^1.1.0-alpha.1:
+ version "1.1.0-alpha.1"
+ resolved "https://registry.yarnpkg.com/eslint-plugin-react-hooks/-/eslint-plugin-react-hooks-1.1.0-alpha.1.tgz#4df0ee992cee25b6b256beb529aa58478e5dc869"
+ integrity sha512-mliA3yxdvED1124X883LEqZhry/c30syJ2hMMOHdiWvqgtPNgf8d7waMxUZx72iAHXwGkt/lGDaWkq5+d9Zn6A==
eslint-plugin-react@^7.12.3:
version "7.12.4"