Skip to content

Commit

Permalink
Merge pull request #43 from gdbroman/0.8.0
Browse files Browse the repository at this point in the history
0.8.0
  • Loading branch information
gdbroman authored Dec 6, 2024
2 parents b37a26b + 7240f92 commit e792668
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"url": "https://github.com/gdbroman"
},
"license": "MIT",
"version": "0.7.0",
"version": "0.8.0",
"main": "dist/index.js",
"module": "dist/index.mjs",
"types": "dist/index.d.ts",
Expand Down
20 changes: 14 additions & 6 deletions src/PromenadeProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,20 +59,28 @@ export const PromenadeProvider = ({
const goForward = useCallback(async () => {
if (isNextDisabled(index)) return;

await onNext?.(index);
try {
await onNext?.(index);

if (index < stepCount - 1) {
setIndex(index + 1);
if (index < stepCount - 1) {
setIndex(index + 1);
}
} catch (error) {
console.error(error);
}
}, [isNextDisabled, index, stepCount, onNext]);

const goBack = useCallback(async () => {
if (isBackDisabled(index)) return;

await onBack?.(index);
try {
await onBack?.(index);

if (index > 0) {
setIndex(index - 1);
if (index > 0) {
setIndex(index - 1);
}
} catch (error) {
console.error(error);
}
}, [isBackDisabled, index, stepCount, onBack]);

Expand Down

0 comments on commit e792668

Please sign in to comment.