mirror of
https://github.com/chinchang/web-maker.git
synced 2025-07-30 18:20:15 +02:00
App: setState migration
This commit is contained in:
@@ -281,19 +281,25 @@ export default class App extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
incrementUnsavedChanges() {
|
incrementUnsavedChanges() {
|
||||||
this.setState({ unsavedEditCount: this.state.unsavedEditCount + 1 });
|
this.setState(prevState => {
|
||||||
|
const newCount = prevState.unsavedEditCount + 1;
|
||||||
|
|
||||||
if (
|
console.log('checking on ', newCount);
|
||||||
this.state.unsavedEditCount % UNSAVED_WARNING_COUNT === 0 &&
|
|
||||||
this.state.unsavedEditCount >= UNSAVED_WARNING_COUNT
|
if (
|
||||||
) {
|
newCount % UNSAVED_WARNING_COUNT === 0 &&
|
||||||
window.saveBtn.classList.add('animated');
|
newCount >= UNSAVED_WARNING_COUNT
|
||||||
window.saveBtn.classList.add('wobble');
|
) {
|
||||||
window.saveBtn.addEventListener('animationend', () => {
|
window.saveBtn.classList.add('animated');
|
||||||
window.saveBtn.classList.remove('animated');
|
window.saveBtn.classList.add('wobble');
|
||||||
window.saveBtn.classList.remove('wobble');
|
window.saveBtn.addEventListener('animationend', () => {
|
||||||
});
|
window.saveBtn.classList.remove('animated');
|
||||||
}
|
window.saveBtn.classList.remove('wobble');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return { unsavedEditCount: newCount };
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
updateProfileUi() {
|
updateProfileUi() {
|
||||||
|
Reference in New Issue
Block a user