🎥 Make videos programmatically with React
remotion: Avoid redundant playback store updates
Noah Lindner4eaf9d51254f
diff --git a/packages/core/src/TimelineContext.tsx b/packages/core/src/TimelineContext.tsxindex 1328af4f6c..8e2961fe48 100644--- a/packages/core/src/TimelineContext.tsx+++ b/packages/core/src/TimelineContext.tsx@@ -140,11 +140,11 @@ export const TimelineContextProvider: React.FC<{return {setFrame,setPlaying: (updater) => {- if (typeof updater === 'function') {- const current = playingStore.store.getSnapshot().playing;- playingStore.setSnapshot({playing: updater(current)});- } else {- playingStore.setSnapshot({playing: updater});+ const current = playingStore.store.getSnapshot().playing;+ const next = typeof updater === 'function' ? updater(current) : updater;++ if (current !== next) {+ playingStore.setSnapshot({playing: next});}},subscribePlaying: playingStore.store.subscribe,diff --git a/packages/player/src/Player.tsx b/packages/player/src/Player.tsxindex 100121b9e4..366c70f14c 100644--- a/packages/player/src/Player.tsx+++ b/packages/player/src/Player.tsx@@ -435,11 +435,11 @@ const PlayerFn = <return {setFrame,setPlaying: (updater) => {- if (typeof updater === 'function') {- const current = playingStore.store.getSnapshot().playing;- playingStore.setSnapshot({playing: updater(current)});- } else {- playingStore.setSnapshot({playing: updater});+ const current = playingStore.store.getSnapshot().playing;+ const next = typeof updater === 'function' ? updater(current) : updater;++ if (current !== next) {+ playingStore.setSnapshot({playing: next});}},subscribePlaying: playingStore.store.subscribe,