mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-11-21 23:16:54 +00:00
Move UnsavedChangesRef into common hook and clean syncing useEffect
This commit is contained in:
1 parent
e2cec264a6
commit
b26d81ca08
4 files changed
+7
-19
No files matched your search
@@ -65,11 +65,6 @@ const HomePage =(props)=>{
|
||||
const editorRef = useRef(null);
|
||||
const lastSavedBrew = useRef(_.cloneDeep(props.brew));
|
||||
const warnUnsavedTimeout = useRef(null);
|
||||
const unsavedChangesRef = useRef(unsavedChanges);
|
||||
|
||||
useEffect(()=>{
|
||||
unsavedChangesRef.current = unsavedChanges;
|
||||
}, [unsavedChanges]);
|
||||
|
||||
const save = ()=>{
|
||||
request.post('/api')
|
||||
@@ -168,7 +163,7 @@ const HomePage =(props)=>{
|
||||
autoSaveEnabled,
|
||||
setAutoSaveEnabled,
|
||||
setWarnUnsavedChanges,
|
||||
unsavedChangesRef,
|
||||
unsavedChanges,
|
||||
setUnsavedChanges,
|
||||
sandbox,
|
||||
lastSavedBrew
|
||||
|
||||
Reference in new issue
Block a user