-
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathApp.js
More file actions
47 lines (40 loc) · 1.08 KB
/
App.js
File metadata and controls
47 lines (40 loc) · 1.08 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
import React, { Component, createRef } from 'react'
import Form from 'formify-react'
import 'formify-react/dist/index.css'
import { formConstants } from './config'
const budgetData = [
{ value: 5000, label: '$5000' },
{ value: 15000, label: '$15000' },
{ value: 25000, label: '$25000' },
{ value: 35000, label: '$35000' },
{ value: 50000, label: '$50000' }
]
const animalData = [
{ value: 'Bear', label: 'Bear' },
{ value: 'Fox', label: 'Fox' },
{ value: 'Cat', label: 'Cat' },
{ value: 'Dog', label: 'Dog' },
{ value: 'Mouse', label: 'Mouse' }
]
export default class App extends Component {
formRef = createRef()
handleSave = () => {
const { current } = this.formRef
const form = current.getFormData()
if (form.isFormValid) {
console.log(form.formData)
}
}
render() {
return (
<div className='container'>
<Form
model={formConstants}
ref={this.formRef}
data={{ budget: budgetData, animals: animalData }}
/>
<button onClick={this.handleSave}>Save</button>
</div>
)
}
}