diff --git a/compiled/facebook-www/REVISION b/compiled/facebook-www/REVISION index 510440e79e071..1a2009d3cf6ed 100644 --- a/compiled/facebook-www/REVISION +++ b/compiled/facebook-www/REVISION @@ -1 +1 @@ -5c8dabf8864e1d826c831d6096b2dfa66309961a +7118f5dd7bf5f1c44d0d2944ef8ad58e423909ad diff --git a/compiled/facebook-www/eslint-plugin-react-hooks.js b/compiled/facebook-www/eslint-plugin-react-hooks.js index 2b2b7b3aa4fc0..cd72678619b97 100644 --- a/compiled/facebook-www/eslint-plugin-react-hooks.js +++ b/compiled/facebook-www/eslint-plugin-react-hooks.js @@ -623,10 +623,20 @@ var RulesOfHooks = { if (isDirectlyInsideComponentOrHook) { - // Report an error if a hook does not reach all finalizing code + // Report an error if the hook is called inside an async function. + var isAsyncFunction = codePathNode.async; + + if (isAsyncFunction) { + context.report({ + node: hook, + message: "React Hook \"" + context.getSource(hook) + "\" cannot be " + 'called in an async function.' + }); + } // Report an error if a hook does not reach all finalizing code // path segments. // // Special case when we think there might be an early return. + + if (!cycled && pathsFromStartToEnd !== allPathsFromStartToEnd && !isUseIdentifier(hook) // `use(...)` can be called conditionally. ) { var message = "React Hook \"" + context.getSource(hook) + "\" is called " + 'conditionally. React Hooks must be called in the exact ' + 'same order in every component render.' + (possiblyHasEarlyReturn ? ' Did you accidentally call a React Hook after an' + ' early return?' : '');