create-react-app 3.3 breaks HMR and linting
See original GitHub issueDescribe the bug
create-react-app 3.3 was released today with support for typescript 3.7.0 features. After updating react-scripts to 3.3.0 and typescript to 3.7.3, HMR and linting stopped working. If I run npm run start
from the command line, everything works as normal. This functionality stopped working when running through visual studio launching the web page via spa.UseReactDevelopmentServer(npmScript: "start")
.
To Reproduce
- Create a new
ASP.NET Core Web Application
project and use theReact.js and Redux
template. Use.NET Core
andASP.NET Core 3.0
settings also. - Open
ClientApp/package.json
and changetypescript
to3.7.3
,react-scripts
to3.3.0
, andeslint
to6.7.2
. - Run the project and open up the developer tools in chrome. You can see in the console output that it never connects. If you have any linting errors, they don’t show up. If you make change to the source files, the page doesn’t reload.
- Go to the command line and into the
ClientApp
directory. Runnpm run start
and this will launch a window on port3000
instead of the random port generated by Visual Studio. Open up chrome developer tools and look at the console. You can see that when running on the command line, that the functionality still works.
Further technical details
.NET Core SDK (reflecting any global.json):
Version: 3.1.100
Commit: cd82f021f4
Runtime Environment:
OS Name: Windows
OS Version: 10.0.18362
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\3.1.100\
Host (useful for support):
Version: 3.1.0
Commit: 65f04fb6db
Visual Studio 16.4.0
Issue Analytics
- State:
- Created 4 years ago
- Reactions:7
- Comments:14 (5 by maintainers)
Top Results From Across the Web
create-react-app/CHANGELOG-3.x.md at main
We now enforce Rules of Hooks with eslint-plugin-react-hooks . If you are breaking any of the rules of Hooks this will cause your...
Read more >Hot Reload is not working in my React App
I have created this app with npx create-react-app. After this i have deleted all the files except index.js in src folder. Then Hot...
Read more >My create-react-app is failing to compile due to ESLint error
It seems that the react-scripts was causing the lint errors for me. The newest version of the react-scripts:"4.0.0" may have some breaking ......
Read more >Hot reloading with create-react-app without ejecting 🔥 ⏏️
With a few lines of code, you can setup a new create-react-app project with hot-module-replacement (HMR). Spin up a new react app with...
Read more >Create-react-app my-app takes 1.5 - 2 hours. Why?
Here's the output I'm getting. My machine is not weak by any means. 2.8 GHz Quad-Core Intel Core i7, 16gb ram, 256 SDD,...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I may misread the code but it appears as if the Middleware for React development server makes an assumption that requests will never use HTTPs, see https://github.com/aspnet/AspNetCore/blob/c7937640a4079465d36441724933eae5a9ca0085/src/Middleware/SpaServices.Extensions/src/ReactDevelopmentServer/ReactDevelopmentServerMiddleware.cs#L45-L51
If I read the code correctly - and that may be a stretch - then this would also explain why switching the project to using HTTP instead of HTTPs when running from within VS works.
Update 05 Jan 2020: Workaround for users of Visual Studio 2019 (we’re on 16.4.2) is to switch to HTTP for debugging locally. It’d be nicer, though, if this was fixed in the extensions package itself, i.e. in Microsoft.AspNetCore.SpaServices.Extensions.
This is a default
create-react-app
setup withtypescript
though, and is fundamental to using react with the SPA templates.I think I found the culprit.
https://github.com/facebook/create-react-app/commit/9f4cb4f0c0ed280fcd6c9faf13ebe2619a398942
If I run my site in http instead of https, everything works as normal.