fix possible React Hooks issues

This commit is contained in:
Pig Fang 2022-02-13 12:09:08 +08:00
parent 8b3376bf9b
commit 424ab20db1
No known key found for this signature in database
GPG Key ID: A8198F548DADA9E2
5 changed files with 9 additions and 2 deletions

View File

@ -8,6 +8,7 @@ extends:
- eslint:recommended - eslint:recommended
- plugin:@typescript-eslint/recommended - plugin:@typescript-eslint/recommended
- plugin:@typescript-eslint/recommended-requiring-type-checking - plugin:@typescript-eslint/recommended-requiring-type-checking
- plugin:react-hooks/recommended
rules: rules:
prefer-const: error prefer-const: error
'@typescript-eslint/no-unsafe-assignment': off '@typescript-eslint/no-unsafe-assignment': off

View File

@ -77,6 +77,7 @@
"css-minimizer-webpack-plugin": "^3.0.1", "css-minimizer-webpack-plugin": "^3.0.1",
"eslint": "^7.4.0", "eslint": "^7.4.0",
"eslint-formatter-beauty": "^3.0.0", "eslint-formatter-beauty": "^3.0.0",
"eslint-plugin-react-hooks": "^4.3.0",
"html-webpack-plugin": "^5.3.1", "html-webpack-plugin": "^5.3.1",
"husky": "^7.0.4", "husky": "^7.0.4",
"jest": "^27.0.4", "jest": "^27.0.4",

View File

@ -5,7 +5,7 @@ export default function useBlessingExtra<T>(key: string, defaultValue?: T): T {
useEffect(() => { useEffect(() => {
setValue(blessing.extra[key] as T) setValue(blessing.extra[key] as T)
}, []) }, [key])
return value return value
} }

View File

@ -14,7 +14,7 @@ export default function useMount(selector: string): HTMLElement | null {
mount.removeChild(div) mount.removeChild(div)
container.current = null container.current = null
} }
}, []) }, [selector])
return container.current return container.current
} }

View File

@ -3687,6 +3687,11 @@ eslint-formatter-beauty@^3.0.0:
code-excerpt "^2.1.1" code-excerpt "^2.1.1"
log-symbols "^2.2.0" log-symbols "^2.2.0"
eslint-plugin-react-hooks@^4.3.0:
version "4.3.0"
resolved "https://registry.yarnpkg.com/eslint-plugin-react-hooks/-/eslint-plugin-react-hooks-4.3.0.tgz#318dbf312e06fab1c835a4abef00121751ac1172"
integrity sha512-XslZy0LnMn+84NEG9jSGR6eGqaZB3133L8xewQo3fQagbQuGt7a63gf+P1NGKZavEYEC3UXaWEAA/AqDkuN6xA==
eslint-scope@5.1.1: eslint-scope@5.1.1:
version "5.1.1" version "5.1.1"
resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-5.1.1.tgz#e786e59a66cb92b3f6c1fb0d508aab174848f48c" resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-5.1.1.tgz#e786e59a66cb92b3f6c1fb0d508aab174848f48c"