Adjust QR state/timeout ordering (#607)

* Adjust QR state/timeout ordering

* CHANGELOG
This commit is contained in:
Jaco
2022-02-01 08:05:09 +01:00
committed by GitHub
parent 35c8535be1
commit 6a279beff3
2 changed files with 7 additions and 3 deletions
+1
View File
@@ -4,6 +4,7 @@
Changes:
- Adjust ordering in state & timeouts for QR display
- Adjust webpack example config (cleanups, remove unneeded plugins)
+6 -3
View File
@@ -69,15 +69,18 @@ function Display ({ className, size, skipEncoding, style, value }: Props): React
timerRef.current.timerDelay = timerRef.current.timerDelay + TIMER_INC;
}
timerRef.current.timerId = setTimeout(nextFrame, timerRef.current.timerDelay);
// only encode the frames on demand, not above as part of the
// state derivation - in the case of large payloads, this should
// be slightly more responsive on initial load
return objectSpread({}, state, {
const newState = objectSpread<FrameState>({}, state, {
frameIdx,
image: getDataUrl(state.frames[frameIdx])
});
// set the new timer last
timerRef.current.timerId = setTimeout(nextFrame, timerRef.current.timerDelay);
return newState;
});
timerRef.current.timerId = window.setTimeout(nextFrame, FRAME_DELAY);