Reputation: 698
I'm starting to learn react. My usual setup is VS Code with Docker-based devcontainers. I used create-react-app to create a really simple app I can play around with. But somehow hot reload doesn't work. Any ideas what the problem could be?
For now, I use a really basic Dockerfile
FROM node:14.17.0
My .devcontainer is also really simple
{
"name": "Try React",
"dockerFile": "Dockerfile",
"runArgs": ["-u", "node"],
}
The console of my browser displays
[HMR] Waiting for update signal from WDS..
as expected. But when I save files nothing happens.
Upvotes: 2
Views: 2990
Reputation: 21
Add the flag CHOKIDAR_USEPOLLING=true so file changes are detected inside the container.
You can either;
CHOKIDAR_USEPOLLING=true npm run start
from the command lineCHOKIDAR_USEPOLLING=true
to a .env file in your project root folderexport CHOKIDAR_USEPOLLING=true
as an environment variable"start": "CHOKIDAR_USEPOLLING=true react-scripts start"
to your package.jsonThis worked for me in a vscode devcontainer using bullseye and React 17
Upvotes: 2