Skip to content
This repository has been archived by the owner on Mar 16, 2024. It is now read-only.

Commit

Permalink
fix: install eslint-plugin-react-hooks and fix errors
Browse files Browse the repository at this point in the history
  • Loading branch information
iiroj committed May 4, 2020
1 parent 1d1e7af commit 411911f
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 26 deletions.
25 changes: 25 additions & 0 deletions .eslintrc.json
@@ -0,0 +1,25 @@
{
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": "tsconfig.json",
"tsconfigRootDir": "."
},
"plugins": [
"@typescript-eslint",
"prettier",
"react-hooks"
],
"extends": [
"plugin:@typescript-eslint/recommended",
"plugin:prettier/recommended",
"prettier",
"prettier/@typescript-eslint"
],
"rules": {
"@typescript-eslint/explicit-function-return-type": 0,
"@typescript-eslint/no-non-null-assertion": 0,
"@typescript-eslint/no-unused-vars": 0,
"react-hooks/exhaustive-deps": 2,
"react-hooks/rules-of-hooks": 2
}
}
20 changes: 0 additions & 20 deletions .eslintrc.yml

This file was deleted.

12 changes: 6 additions & 6 deletions index.tsx
Expand Up @@ -119,12 +119,12 @@ const StickyNav = React.forwardRef<HTMLDivElement, Props>(

prevScroll.current = scroll;
animation.current = null;
}, [disabled, !!render]);
}, [disabled, ref, render]);

const handleScroll = () => {
const handleScroll = React.useCallback(() => {
if (animation.current) window.cancelAnimationFrame(animation.current);
animation.current = window.requestAnimationFrame(handleAnimateTop);
};
}, [handleAnimateTop]);

const handleAddEventListener = React.useCallback(() => {
if (typeof (window as UndefinedWindow) !== "undefined") {
Expand All @@ -141,12 +141,12 @@ const StickyNav = React.forwardRef<HTMLDivElement, Props>(
React.useEffect(() => {
if (disabled) handleRemoveEventListener();
else handleAddEventListener();
return () => handleAddEventListener();
}, [disabled]);
return () => handleRemoveEventListener();
}, [disabled, handleAddEventListener, handleRemoveEventListener]);

React.useEffect(() => {
if (!disabled) handleAnimateTop();
}, []);
}, [disabled, handleAnimateTop]);

if (render) {
return render({ position, ref, top: renderTop });
Expand Down
6 changes: 6 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Expand Up @@ -64,6 +64,7 @@
"eslint": "^6.8.0",
"eslint-config-prettier": "^6.11.0",
"eslint-plugin-prettier": "^3.1.3",
"eslint-plugin-react-hooks": "4.0.0",
"husky": "^4.2.5",
"lint-staged": "^10.2.2",
"parcel-bundler": "1.12.4",
Expand Down

0 comments on commit 411911f

Please sign in to comment.