Skip to content

Commit

Permalink
Merge pull request #41 from gdbroman/0.7.0
Browse files Browse the repository at this point in the history
0.7.0
  • Loading branch information
gdbroman authored Dec 5, 2024
2 parents b2e21e5 + a5663d5 commit 47c2293
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 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.6.0",
"version": "0.7.0",
"main": "dist/index.js",
"module": "dist/index.mjs",
"types": "dist/index.d.ts",
Expand Down
4 changes: 2 additions & 2 deletions src/PromenadeContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ type PromenadeContextType = {
* Whether the next button is loading
* @default () => false
*/
isNextLoading?: boolean;
isNextLoading: boolean;
/**
* Whether the back button is loading
* @default () => false
* */
isBackLoading?: boolean;
isBackLoading: boolean;
/**
* Function to go forward to the next step.
*/
Expand Down
12 changes: 6 additions & 6 deletions src/PromenadeProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ type PromenadeProviderProps = {
/**
* Callback for when the user clicks the back button
*/
onBack?: (index: number) => void;
onBack?: (index: number) => void | Promise<void>;
/**
* Callback for when the user clicks the next button
*/
onNext?: (index: number) => void;
onNext?: (index: number) => void | Promise<void>;
};

export const PromenadeProvider = ({
Expand All @@ -56,20 +56,20 @@ export const PromenadeProvider = ({
}: PromenadeProviderProps) => {
const [index, setIndex] = useState(0);

const goForward = useCallback(() => {
const goForward = useCallback(async () => {
if (isNextDisabled(index)) return;

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

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

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

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

if (index > 0) {
setIndex(index - 1);
Expand Down

0 comments on commit 47c2293

Please sign in to comment.