diff --git a/.eslintrc b/.eslintrc index d2d267da..0d6250be 100644 --- a/.eslintrc +++ b/.eslintrc @@ -22,7 +22,8 @@ ], "plugins": [ "promise", - "react" + "react", + "react-hooks" ], "env": { "es6": true, @@ -160,6 +161,10 @@ "react/self-closing-comp": 2, "react/sort-comp": 0, "react/sort-prop-types": 2, - "react/wrap-multilines": 0 + "react/wrap-multilines": 0, + + // react-hooks + "react-hooks/rules-of-hooks": "error", + "react-hooks/exhaustive-deps": "warn" } } diff --git a/package.json b/package.json index 75f52d30..56cc91a1 100644 --- a/package.json +++ b/package.json @@ -48,6 +48,7 @@ "eslint-config-prettier": "^6.4.0", "eslint-plugin-promise": "^4.2.1", "eslint-plugin-react": "^7.16.0", + "eslint-plugin-react-hooks": "^2.3.0", "flow-bin": "^0.109.0", "glob": "^7.1.4", "husky": "^3.0.8", diff --git a/packages/docs/src/apis/AppState/examples/StateChanges.js b/packages/docs/src/apis/AppState/examples/StateChanges.js index cd589b34..bae96363 100644 --- a/packages/docs/src/apis/AppState/examples/StateChanges.js +++ b/packages/docs/src/apis/AppState/examples/StateChanges.js @@ -8,19 +8,19 @@ export default function StateChanges() { currentState: AppState.currentState }); - const handleChange = nextState => { - updateState(previousState => ({ - ...previousState, - [nextState]: previousState[nextState] + 1 - })); - }; - React.useEffect(() => { + const handleChange = nextState => { + updateState(previousState => ({ + ...previousState, + [nextState]: previousState[nextState] + 1 + })); + }; + AppState.addEventListener('change', handleChange); return () => { AppState.removeEventListener('change', handleChange); }; - }, [handleChange]); + }, []); return ( diff --git a/packages/react-native-web/src/hooks/usePlatformMethods.js b/packages/react-native-web/src/hooks/usePlatformMethods.js index d7805dcc..b6c543fb 100644 --- a/packages/react-native-web/src/hooks/usePlatformMethods.js +++ b/packages/react-native-web/src/hooks/usePlatformMethods.js @@ -70,6 +70,6 @@ export default function usePlatformMethods( } }; }, - [classList, hostRef, ref, style] + [classList, hostRef, style] ); } diff --git a/yarn.lock b/yarn.lock index 9501ae6c..245f5c32 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7006,6 +7006,11 @@ eslint-plugin-promise@^4.2.1: resolved "https://registry.yarnpkg.com/eslint-plugin-promise/-/eslint-plugin-promise-4.2.1.tgz#845fd8b2260ad8f82564c1222fce44ad71d9418a" integrity sha512-VoM09vT7bfA7D+upt+FjeBO5eHIJQBUWki1aPvB+vbNiHS3+oGIJGIeyBtKQTME6UPXXy3vV07OL1tHd3ANuDw== +eslint-plugin-react-hooks@^2.3.0: + version "2.3.0" + resolved "https://registry.yarnpkg.com/eslint-plugin-react-hooks/-/eslint-plugin-react-hooks-2.3.0.tgz#53e073961f1f5ccf8dd19558036c1fac8c29d99a" + integrity sha512-gLKCa52G4ee7uXzdLiorca7JIQZPPXRAQDXV83J4bUEeUuc5pIEyZYAZ45Xnxe5IuupxEqHS+hUhSLIimK1EMw== + eslint-plugin-react@^7.16.0: version "7.16.0" resolved "https://registry.yarnpkg.com/eslint-plugin-react/-/eslint-plugin-react-7.16.0.tgz#9928e4f3e2122ed3ba6a5b56d0303ba3e41d8c09"