I have a react/redux app and when file changes and I hit save it refreshes the page and clears all redux data.I know t that I can persist redux data to localstorage. What I would love to know is that is it the default behaviour of react/node server to refresh the page when file changes? If not how can I prevent it?
page refreshes when file is changed react
6.2k Views Asked by sparrow2 At
1
There are 1 best solutions below
Related Questions in REACTJS
- What is `_dereq_()` inside React?
- React TypeError: React.renderComponent is not a function
- React - saving a component in the ref callback
- React Rails component: manually triggering a re-render
- React, ES6 - getInitialState was defined on a plain JavaScript class
- How to get multiple selected options value in React JS?
- React.render replace container instead of inserting into
- reactjs datagrid use html
- props is not initialized in react component
- How to display xml data using Reactjs
- hooking up the data model in ReactJS - syntax
- ReactJS: How to use an immutable empty array or object
- How to use Sinon.js FakeXMLHttpRequest with superagent?
- React select onChange is not working
- ReactJS - Tutorial Comment System > Threaded commenting
Related Questions in WEBPACK
- RequireJS shim config in webpack
- Webpack Uglify plugin returns "Killed" on Ubuntu
- Log to node console or debug during webpack build
- Gulp with WebPack. Which should be building my coffee/jade etc.?
- Webpack: silence output
- Webpack: Must i specify the domain in publicPath for url() directive to work in CSS?
- webpack-dev-server & jsxhint: const '$__0' has already been declared
- Use Webpack to split out a module so that it can be loaded in a WebWorker
- oclazyLoad with webpack to support lazy loading for Angularjs is not working on minification
- How to make webpack to produce only one file and include all chunks?
- Reduce transpiled code helpers with babel and webpack
- webpack sass compliation stuck, however same works with similar other file also same problamatic sass file works with gulp-sass module
- Webpack html-loader returns full module definition
- Webpack: Create a bundle with each file in directory
- Include paths for imports in babel using webpack
Related Questions in REDUX
- How to split routes to different files with Redux and React-router?
- redux-saga, TypeError: (0 , _effects.takeLatest) is not a function?
- Expose Redux store api using webpack instead of global
- Using the Angular 2 Http client in order to rehydrate application state in a ngrx meta reducer
- Redux-thunk dispatch is not a function
- show 10 results per page
- Replicating the action on redux-thunk to redux-saga
- redux-saga: tracking multiple async tasks
- Redux saga, rx-observable. With vanilla fetch calls, why the need over thunks?
- Handling many entities on Redux without repetition
- React Native & Redux props correct design pattern
- React native + redux-persist: how to ignore keys (blacklist)?
- How to cancel execution of a previous action upon a new action?
- What is the use of the ownProps arg in mapStateToProps and mapDispatchToProps?
- Concat actually concatenates instead of adds to array. React Native Javascript
Related Questions in REACT-HOT-LOADER
- WebSocket connection failed. Error during WebSocket handshake - socketjs
- How to automatically remove *.hot-update.json files when using react-hot-loader package?
- react-hot-loader and webpack not working
- Is it possible to HMR a resource on a remote server?
- React hot loading does not work even after configuration
- Correctly linking to webpack-dev-server bundle in php site
- How can I update ONLY ONE component? Table
- React Material-UI Webpack Hot Reload Injecting Duplicate Styles in <head> on Save
- hot-module-loader apply cold to node_module package
- React module doesn't import correctly into another as dependency
- react-hot-loader + error boundaries: how to clear error after hot update?
- Using react-hot-loader with Babel 6
- react-hot-loader and webpack
- page refreshes when file is changed react
- How to enable hot reload when using Webpack in watch mode and Firebase emulators:start
Related Questions in HOT-RELOAD
- Preact SSR hot reload/rebuild
- Hot reloading with typescript and node
- How to make react-refresh auto-update components properly with mobx?
- webpack hot reload for html files not working in multi entry files
- Why hot reload on my react project is so slow in docker?
- Hot reloading in vue.js app doesn't work on docker
- React with SSR and WebpackHotMiddleware
- ng-server reload page but not really update until I manually refresh
- VSCode launch.json to run C# project with dotnet watch / hot reload
- Is there a way to add the Visual Studio 2022 hot reload button to Rider?
- How to enable hot reload in an Angular/Spring-Boot app using Docker?
- Flutter hot reload not working with ctrl+s
- Vite 5.0 - Hot Reload not working after upgrading from 4.5.0
- Can maven open-liberty plugin hot-reload single class file without stopping and restarting the whole application?
- How to can I sync changes in Chrome DevTools "Styles" pane to original Source for a webpack website?
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
Is it a default behaviour? : YES, it is.
This is known as
live-reloadingwhere a change in your file refreshes your local server and restarts the app setting all state to initial ones.But the problem as you mentioned is that the state of the app is lost.
There is another concept called
hot-reloadingwhich prevents it. Hot reloading will just replace the modules which have changed while the app is running. This won't cause a total refresh of the app. It will just update the page with the changes without a reload, and so will maintain the state of the app. However, the state of the component,i.e, the react state isn't maintained.Now, when you create a react project using CRA, the hot reload feature is built in. You can try it by running your app and changing some css. You will notice that the app doesn't refresh but the changes are applied!!
However, if you try doing this in a JSX file, the entire app changes. This is because there are some changes that needs to be done to enable hot reloading in a JSX file.
Go to the index.js and write this line of code:
If you go and make a change to your JSX file now, you will see that the updates are applied without refresh.
BUT, the react state aren't maintained. There is a library called the
react-hot-loader, which can help you in maintaining the react state too.Try it out!