Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading