From 90b6e3d3c5526e4f3db891019969f7cfddc11958 Mon Sep 17 00:00:00 2001 From: Lennart Date: Fri, 15 Jan 2021 16:02:12 +0100 Subject: [PATCH] fix(gatsby): Use fast-refresh for React 17 (#28930) --- .../gatsby/src/utils/get-react-hot-loader-strategy.ts | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/packages/gatsby/src/utils/get-react-hot-loader-strategy.ts b/packages/gatsby/src/utils/get-react-hot-loader-strategy.ts index 7c713b1b990d6..3b817d05b6978 100644 --- a/packages/gatsby/src/utils/get-react-hot-loader-strategy.ts +++ b/packages/gatsby/src/utils/get-react-hot-loader-strategy.ts @@ -1,4 +1,4 @@ -// import semver from "semver" +import semver from "semver" // Fast refresh is supported as of React 16.9. // This package will do some sniffing to see if the current version of @@ -13,22 +13,15 @@ export function getReactHotLoaderStrategy(): string { // Do some package sniffing to see if we can use fast-refresh if the user didn't // specify a specific hot loader with the environment variable. - // TODO: Probably use the flags for this - /* try { const reactVersion = require(`react/package.json`).version - // TODO React components need to be named to make fast-refresh work - // We need to create an eslint-rule that shows this error or create a babel plugin - // that converts arrow functions to generated named ones. - // When it's available we can switch the condition to >=16.9.0 if (semver.satisfies(reactVersion, `>=17.0.0`)) { return `fast-refresh` } } catch (e) { return `react-hot-loader` } - */ return `react-hot-loader` }