Skip to content

Commit

Permalink
fix(gatsby): Use fast-refresh for React 17 (#28930)
Browse files Browse the repository at this point in the history
  • Loading branch information
LekoArts committed Jan 15, 2021
1 parent 9a55d12 commit 90b6e3d
Showing 1 changed file with 1 addition and 8 deletions.
9 changes: 1 addition & 8 deletions 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
Expand All @@ -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`
}

0 comments on commit 90b6e3d

Please sign in to comment.