Search code examples
reactjscreate-react-app

Create react app, reload not working


I just started coding in React using create-react-app. In the documentation it's said

The page will reload if you make edits.

I don't know which module is responsible for auto reload (webpack or react-hot-reloader?) but it's not working. I edited file using different editors (Sublime, VIM, ..) but it seems problem is for something else. Any advice how to debug it?


Solution

  • After too many searches I found Webpack watch uses inotify to observe file changes and in ubuntu it's set to a low value. a quick fix:

    sudo -i
    echo 1048576 > /proc/sys/fs/inotify/max_user_watches
    exit
    

    If you want change it permanently (from Ronald answer):

    echo "fs.inotify.max_user_watches=524288" >> /etc/sysctl.conf
    sudo sysctl -p
    

    You may also need to add a .env file in the root directory of your project with this line "FAST_REFRESH=false" as noted in create react app docs.

    echo "FAST_REFRESH=false\n" | cat > .env