-
Notifications
You must be signed in to change notification settings - Fork 45
Expand file tree
/
Copy pathasyncStep.tsx
More file actions
61 lines (51 loc) · 1.1 KB
/
asyncStep.tsx
File metadata and controls
61 lines (51 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import { styled } from 'goober';
import * as React from 'react';
import { useWizard } from '../../dist';
import { BaseWizardStep } from '../../dist/types';
import { useMockMutation } from '../hooks';
type Props = BaseWizardStep & {
content: string;
};
const MOCK = [
{
id: 1,
name: 'Tony Stark',
},
{
id: 2,
name: 'Bruce Banner',
},
];
const Container = styled('div')`
background: var(--step);
border: 1px solid #250b46;
border-radius: 2px;
padding: 2.75rem 0.35rem;
display: flex;
flex-direction: column;
min-height: 15vh;
justify-content: center;
align-items: center;
`;
const P = styled('p')`
color: var(--text);
`;
const AsyncStep: React.FC<Props> = React.memo(({ number }) => {
const [mutate] = useMockMutation(MOCK);
const { handleStep, isLoading } = useWizard();
// Also works
handleStep(async () => {
await mutate();
});
// Alternative
// handleStep(() => {
// return mutate();
// });
return (
<Container>
<P>(Async) Step {number}</P>
{isLoading && <P>Loading...</P>}
</Container>
);
});
export default AsyncStep;