Created
June 14, 2019 23:16
-
-
Save zackshapiro/65fac6ee5056fb0912220022003aa2c8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const countRef = useRef(0) | |
// Processes the next pending thumbnail when ready | |
useEffect(() => { | |
if (state.pending.length && state.next) { | |
const { next } = state | |
api | |
.uploadFile(next) | |
.then(() => { | |
const prev = next | |
logUploadedFile(++countRef.current) | |
const pending = state.pending.slice(1) | |
dispatch({ type: 'file-uploaded', prev, pending }) | |
}) | |
.catch((error) => { | |
console.error(error) | |
dispatch({ type: 'set-upload-error', error }) | |
}) | |
} | |
}, [state]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment