File tree 3 files changed +8
-16
lines changed 3 files changed +8
-16
lines changed Original file line number Diff line number Diff line change @@ -243,7 +243,7 @@ function tryApplyUpdates(onHotUpdateSuccess) {
243
243
}
244
244
245
245
function handleApplyUpdates ( err , updatedModules ) {
246
- const hasReactRefresh = process . env . FAST_REFRESH !== 'false' ;
246
+ const hasReactRefresh = process . env . FAST_REFRESH ;
247
247
const wantsForcedReload = err || ! updatedModules || hadRuntimeError ;
248
248
// React refresh can handle hot-reloading over errors.
249
249
if ( ! hasReactRefresh && wantsForcedReload ) {
Original file line number Diff line number Diff line change 11
11
const fs = require ( 'fs' ) ;
12
12
const path = require ( 'path' ) ;
13
13
const paths = require ( './paths' ) ;
14
+ const semver = require ( 'semver' ) ;
15
+ const react = require ( require . resolve ( 'react' , { paths : [ paths . appPath ] } ) ) ;
14
16
15
17
// Make sure that including paths.js after env.js will read .env variables.
16
18
delete require . cache [ require . resolve ( './paths' ) ] ;
@@ -94,10 +96,12 @@ function getClientEnvironment(publicUrl) {
94
96
WDS_SOCKET_PATH : process . env . WDS_SOCKET_PATH ,
95
97
WDS_SOCKET_PORT : process . env . WDS_SOCKET_PORT ,
96
98
// Whether or not react-refresh is enabled.
97
- // react-refresh is not 100% stable at this time,
98
- // which is why it's disabled by default.
99
99
// It is defined here so it is available in the webpackHotDevClient.
100
- FAST_REFRESH : process . env . FAST_REFRESH !== 'false' ,
100
+ // Fast Refresh is available in React 16.10.0 or greater
101
+ // For older versions will fallback to full reload
102
+ FAST_REFRESH :
103
+ semver . gte ( react . version , '16.10.0' ) &&
104
+ process . env . FAST_REFRESH !== 'false' ,
101
105
}
102
106
) ;
103
107
// Stringify all values so we can feed into webpack DefinePlugin
Original file line number Diff line number Diff line change @@ -44,14 +44,10 @@ const {
44
44
prepareUrls,
45
45
} = require ( 'react-dev-utils/WebpackDevServerUtils' ) ;
46
46
const openBrowser = require ( 'react-dev-utils/openBrowser' ) ;
47
- const semver = require ( 'semver' ) ;
48
47
const paths = require ( '../config/paths' ) ;
49
48
const configFactory = require ( '../config/webpack.config' ) ;
50
49
const createDevServerConfig = require ( '../config/webpackDevServer.config' ) ;
51
- const getClientEnvironment = require ( '../config/env' ) ;
52
- const react = require ( require . resolve ( 'react' , { paths : [ paths . appPath ] } ) ) ;
53
50
54
- const env = getClientEnvironment ( paths . publicUrlOrPath . slice ( 0 , - 1 ) ) ;
55
51
const useYarn = fs . existsSync ( paths . yarnLockFile ) ;
56
52
const isInteractive = process . stdout . isTTY ;
57
53
@@ -147,14 +143,6 @@ checkBrowsers(paths.appPath, isInteractive)
147
143
clearConsole ( ) ;
148
144
}
149
145
150
- if ( env . raw . FAST_REFRESH && semver . lt ( react . version , '16.10.0' ) ) {
151
- console . log (
152
- chalk . yellow (
153
- `Fast Refresh requires React 16.10 or higher. You are using React ${ react . version } .`
154
- )
155
- ) ;
156
- }
157
-
158
146
console . log ( chalk . cyan ( 'Starting the development server...\n' ) ) ;
159
147
openBrowser ( urls . localUrlForBrowser ) ;
160
148
} ) ;
You can’t perform that action at this time.
0 commit comments