handling state-sync in react component