From 8dc1de4913e30db1cfe569176ab645a8d3a7e5b5 Mon Sep 17 00:00:00 2001 From: Eivind Arvesen Date: Sun, 17 Feb 2019 21:50:44 +0100 Subject: [PATCH] Force array destructuring to work in loose mode only for known Hooks --- packages/babel-preset-react-app/create.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/packages/babel-preset-react-app/create.js b/packages/babel-preset-react-app/create.js index 439a3058404..dfff10d5223 100644 --- a/packages/babel-preset-react-app/create.js +++ b/packages/babel-preset-react-app/create.js @@ -122,6 +122,18 @@ module.exports = function(api, opts, env) { // Use loose mode for performance: // https://github.com/facebook/create-react-app/issues/5602 loose: true, + selectiveLoose: [ + 'useState', + 'useEffect', + 'useContext', + 'useReducer', + 'useCallback', + 'useMemo', + 'useRef', + 'useImperativeHandle', + 'useLayoutEffect', + 'useDebugValue', + ], }, ], // Turn on legacy decorators for TypeScript files