Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(gatsby): Use fast-refresh for React 17 #28930

Merged
merged 1 commit into from
Jan 15, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 1 addition & 8 deletions packages/gatsby/src/utils/get-react-hot-loader-strategy.ts
Original file line number Diff line number Diff line change
@@ -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`
}