-
-
Notifications
You must be signed in to change notification settings - Fork 70
/
Copy pathFieldArray.js
47 lines (42 loc) · 904 Bytes
/
FieldArray.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
// @flow
import { version as ffVersion } from 'final-form'
import { version as rffVersion } from 'react-final-form'
import type { FieldArrayProps } from './types'
import renderComponent from './renderComponent'
import useFieldArray from './useFieldArray'
import { version } from '../package.json'
export { version }
const versions = {
'final-form': ffVersion,
'react-final-form': rffVersion,
'react-final-form-arrays': version
}
const FieldArray = ({
name,
subscription,
defaultValue,
initialValue,
isEqual,
validate,
...rest
}: FieldArrayProps) => {
const { fields, meta } = useFieldArray(name, {
subscription,
defaultValue,
initialValue,
isEqual,
validate
})
return renderComponent(
{
fields,
meta: {
...meta,
__versions: versions
},
...rest
},
`FieldArray(${name})`
)
}
export default FieldArray