reactjs - Check is there are unsaved changes in a redux app -


i'm looking example of how check changes in react-redux application. application prompt user unsaved changes when attempting navigate away current route.

thank in advance.

doing involve in component:

onclicknavigationlink = () => {   const { checklocalstate } = this.props;   checklocalstate() // have access cause of `connect`     .then(res => {       if (res.arechanges) {         this.setstate({ proptuserconfirmation: true })       } else {         this.onclicknavigationconfirmation();       }     }) }  onclicknavigationconfirmation = () => {   const { push } = this.props;    push('/nexturl'); } 

and action like

function checklocalstate() {   return (dispatch, getstate) => {     return api.checklocalstate(getstate());   } } 

this require server-side service can diff local state , redux state tree. don't recommend general pattern begin with, however. should know in local application state if user has unsaved data.


Comments

Popular posts from this blog

android - net_scheduler holding wakelock -

sql - MySQL : Getting Entries from a many-to-many table -

java - Retrieving data from database using jsp (Hibernate + Spring + Maven) -