Skip to content

Commit f73f4e9

Browse files
committed
chore: use promise instead of async await
1 parent 3c9bf57 commit f73f4e9

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
"test:coverage": "tsdx test --coverage",
5656
"lint": "tsdx lint",
5757
"prepare": "tsdx build",
58-
"size": "size-limit",
58+
"size": "yarn build && size-limit",
5959
"analyze": "size-limit --why",
6060
"release": "np"
6161
},

src/wizard.tsx

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,17 @@ const Wizard: React.FC<WizardProps> = React.memo(
3535

3636
const doNextStep = React.useCallback(async () => {
3737
if (hasNextStep.current && nextStepHandler.current) {
38-
try {
39-
setIsLoading(true);
40-
await nextStepHandler.current();
41-
setIsLoading(false);
42-
nextStepHandler.current = null;
43-
goToNextStep();
44-
} catch (error) {
45-
setIsLoading(false);
46-
throw error;
47-
}
38+
setIsLoading(true);
39+
Promise.resolve(nextStepHandler.current)
40+
.then(() => {
41+
setIsLoading(false);
42+
nextStepHandler.current = null;
43+
return goToNextStep();
44+
})
45+
.catch((error) => {
46+
setIsLoading(false);
47+
throw error;
48+
});
4849
} else {
4950
goToNextStep();
5051
}

0 commit comments

Comments
 (0)