1
0
mirror of https://github.com/chinchang/web-maker.git synced 2025-08-02 11:30:22 +02:00

App: setState migration

This commit is contained in:
Kushagra Gour
2019-07-16 01:24:17 +05:30
parent 60e1de8203
commit be02762620

View File

@@ -281,11 +281,14 @@ export default class App extends Component {
} }
incrementUnsavedChanges() { incrementUnsavedChanges() {
this.setState({ unsavedEditCount: this.state.unsavedEditCount + 1 }); this.setState(prevState => {
const newCount = prevState.unsavedEditCount + 1;
console.log('checking on ', newCount);
if ( if (
this.state.unsavedEditCount % UNSAVED_WARNING_COUNT === 0 && newCount % UNSAVED_WARNING_COUNT === 0 &&
this.state.unsavedEditCount >= UNSAVED_WARNING_COUNT newCount >= UNSAVED_WARNING_COUNT
) { ) {
window.saveBtn.classList.add('animated'); window.saveBtn.classList.add('animated');
window.saveBtn.classList.add('wobble'); window.saveBtn.classList.add('wobble');
@@ -294,6 +297,9 @@ export default class App extends Component {
window.saveBtn.classList.remove('wobble'); window.saveBtn.classList.remove('wobble');
}); });
} }
return { unsavedEditCount: newCount };
});
} }
updateProfileUi() { updateProfileUi() {