diff --git a/package.json b/package.json index 1473a91..8b0e692 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/PromenadeProvider.tsx b/src/PromenadeProvider.tsx index 6434724..bae6adf 100644 --- a/src/PromenadeProvider.tsx +++ b/src/PromenadeProvider.tsx @@ -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]);