-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathindex.js
executable file
·50 lines (44 loc) · 935 Bytes
/
index.js
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
import FormikWizard from 'formik-wizard'
import React from 'react'
import steps from './steps'
function FormWrapper({
children,
isLastStep,
status,
goToPreviousStep,
canGoBack,
actionLabel,
}) {
return (
<div>
{status && (
<div>
{status.message}
<hr />
</div>
)}
<div>
<button type="button" onClick={goToPreviousStep} disabled={!canGoBack}>
Previous
</button>
<button type="submit">
{actionLabel || (isLastStep ? 'Submit' : 'Next step')}
</button>
</div>
<hr />
{children}
</div>
)
}
function App() {
const handleSubmit = React.useCallback((values) => {
console.log('full values:', values)
return {
message: 'Thanks for submitting!',
}
}, [])
return (
<FormikWizard steps={steps} onSubmit={handleSubmit} render={FormWrapper} />
)
}
export default App