diff --git a/packages/react-devtools-shared/src/devtools/views/Profiler/SnapshotSelector.js b/packages/react-devtools-shared/src/devtools/views/Profiler/SnapshotSelector.js
index 5d9424211af8f..41979cee6b9f5 100644
--- a/packages/react-devtools-shared/src/devtools/views/Profiler/SnapshotSelector.js
+++ b/packages/react-devtools-shared/src/devtools/views/Profiler/SnapshotSelector.js
@@ -95,20 +95,20 @@ export default function SnapshotSelector(_: Props) {
const viewNextCommit = useCallback(
() => {
- const nextCommitIndex = Math.min(
- ((selectedFilteredCommitIndex: any): number) + 1,
- filteredCommitIndices.length - 1,
- );
+ let nextCommitIndex = ((selectedFilteredCommitIndex: any): number) + 1;
+ if (nextCommitIndex === filteredCommitIndices.length) {
+ nextCommitIndex = 0;
+ }
selectCommitIndex(filteredCommitIndices[nextCommitIndex]);
},
[selectedFilteredCommitIndex, filteredCommitIndices, selectCommitIndex],
);
const viewPrevCommit = useCallback(
() => {
- const nextCommitIndex = Math.max(
- ((selectedFilteredCommitIndex: any): number) - 1,
- 0,
- );
+ let nextCommitIndex = ((selectedFilteredCommitIndex: any): number) - 1;
+ if (nextCommitIndex < 0) {
+ nextCommitIndex = filteredCommitIndices.length - 1;
+ }
selectCommitIndex(filteredCommitIndices[nextCommitIndex]);
},
[selectedFilteredCommitIndex, filteredCommitIndices, selectCommitIndex],
@@ -141,7 +141,7 @@ export default function SnapshotSelector(_: Props) {
{label}