Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit f88ee07

Browse files
authored
Rewrote to use useField hook and provide useFieldArray hook (#80)
* Rewrote to use useField hook and provide useFieldArray hook * TOC * Documented isEqual default * Hook test
1 parent 7327701 commit f88ee07

18 files changed

+2710
-1713
lines changed

‎README.md‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ const MyForm = () => (
8585
- [Rendering](#rendering)
8686
- [API](#api)
8787
- [`FieldArray : React.ComponentType<FieldArrayProps>`](#fieldarray--reactcomponenttypefieldarrayprops)
88+
- [`useFieldArray`](#usefieldarray)
8889
- [`version: string`](#version-string)
8990
- [Types](#types)
9091
- [`FieldArrayProps`](#fieldarrayprops)
@@ -154,6 +155,12 @@ The following can be imported from `react-final-form-arrays`.
154155
A component that takes [`FieldArrayProps`](#fieldarrayprops) and renders an
155156
array of fields
156157

158+
### `useFieldArray`
159+
160+
The `useFieldArray` hook takes two parameters, the first is the name of the field, and the second is an optional object that looks just like [`FieldArrayProps`](#fieldarrayprops), except without the name. It returns an object just like [`FieldArrayRenderProps`](#fieldarrayrenderprops).
161+
162+
`useFieldArray` is used interally inside `FieldArray`.
163+
157164
### `version: string`
158165

159166
The current used version of 🏁 React Final Form Arrays.
@@ -191,7 +198,7 @@ passed into the `<FieldArray/>` component.
191198

192199
#### `isEqual?: (allPreviousValues: Array<any>, allNewValues: Array<any>) => boolean`
193200

194-
A function that can be used to compare two arrays of values (before and after every change) and calculate pristine/dirty checks.
201+
A function that can be used to compare two arrays of values (before and after every change) and calculate pristine/dirty checks. Defaults to a function that will `===` check each element of the array.
195202

196203
#### `subscription?: FieldSubscription`
197204

‎package-lock.json‎

Lines changed: 1968 additions & 982 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json‎

Lines changed: 36 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -25,64 +25,67 @@
2525
},
2626
"homepage": "https://github.com/final-form/react-final-form-arrays#readme",
2727
"devDependencies": {
28-
"@babel/core": "^7.3.4",
29-
"@babel/plugin-proposal-class-properties": "^7.3.4",
30-
"@babel/plugin-proposal-decorators": "^7.3.0",
28+
"@babel/core": "^7.4.5",
29+
"@babel/plugin-proposal-class-properties": "^7.4.4",
30+
"@babel/plugin-proposal-decorators": "^7.4.4",
3131
"@babel/plugin-proposal-export-namespace-from": "^7.2.0",
3232
"@babel/plugin-proposal-function-sent": "^7.2.0",
3333
"@babel/plugin-proposal-json-strings": "^7.2.0",
3434
"@babel/plugin-proposal-numeric-separator": "^7.2.0",
3535
"@babel/plugin-proposal-throw-expressions": "^7.2.0",
3636
"@babel/plugin-syntax-dynamic-import": "^7.2.0",
3737
"@babel/plugin-syntax-import-meta": "^7.2.0",
38-
"@babel/plugin-transform-flow-strip-types": "^7.3.4",
39-
"@babel/plugin-transform-runtime": "^7.3.4",
40-
"@babel/preset-env": "^7.3.4",
38+
"@babel/plugin-transform-flow-strip-types": "^7.4.4",
39+
"@babel/plugin-transform-runtime": "^7.4.4",
40+
"@babel/preset-env": "^7.4.5",
4141
"@babel/preset-flow": "^7.0.0",
4242
"@babel/preset-react": "^7.0.0",
43-
"@types/react": "^16.8.6",
43+
"@types/react": "^16.8.18",
4444
"babel-core": "^7.0.0-bridge.0",
4545
"babel-eslint": "^10.0.1",
46-
"babel-jest": "^24.1.0",
47-
"bundlesize": "^0.17.1",
46+
"babel-jest": "^24.8.0",
47+
"bundlesize": "^0.17.2",
4848
"doctoc": "^1.4.0",
49-
"eslint": "^5.15.0",
50-
"eslint-config-react-app": "^3.0.7",
49+
"eslint": "^5.16.0",
50+
"eslint-config-react-app": "^4.0.1",
5151
"eslint-plugin-babel": "^5.2.1",
52-
"eslint-plugin-flowtype": "^3.4.2",
53-
"eslint-plugin-import": "^2.16.0",
52+
"eslint-plugin-flowtype": "^3.9.1",
53+
"eslint-plugin-import": "^2.17.3",
5454
"eslint-plugin-jsx-a11y": "^6.2.1",
55-
"eslint-plugin-react": "^7.12.4",
56-
"final-form": "^4.11.1",
55+
"eslint-plugin-react": "^7.13.0",
56+
"eslint-plugin-react-hooks": "^1.6.0",
57+
"final-form": "^4.13.0",
5758
"final-form-arrays": "^1.1.2",
58-
"flow-bin": "^0.94.0",
59+
"flow-bin": "^0.98.1",
5960
"glow": "^1.2.2",
60-
"husky": "^1.3.1",
61-
"jest": "^24.1.0",
62-
"jest-watch-typeahead": "^0.2.1",
63-
"lint-staged": "^8.1.5",
64-
"nps": "^5.9.4",
61+
"husky": "^2.3.0",
62+
"jest": "^24.8.0",
63+
"jest-dom": "^3.4.0",
64+
"jest-watch-typeahead": "^0.3.1",
65+
"lint-staged": "^8.1.7",
66+
"nps": "^5.9.5",
6567
"nps-utils": "^1.7.0",
66-
"prettier": "^1.16.4",
68+
"prettier": "^1.17.1",
6769
"prettier-eslint-cli": "^4.7.1",
6870
"raf": "^3.4.0",
69-
"react": "^16.8.3",
70-
"react-dom": "^16.8.3",
71-
"react-final-form": "^4.0.2",
72-
"rollup": "^1.4.1",
71+
"react": "^16.8.6",
72+
"react-dom": "^16.8.6",
73+
"react-final-form": "^6.0.0",
74+
"react-testing-library": "^7.0.1",
75+
"rollup": "^1.12.4",
7376
"rollup-plugin-babel": "^4.3.2",
74-
"rollup-plugin-commonjs": "^9.2.1",
75-
"rollup-plugin-node-resolve": "^4.0.1",
76-
"rollup-plugin-replace": "^2.1.0",
77+
"rollup-plugin-commonjs": "^10.0.0",
78+
"rollup-plugin-node-resolve": "^5.0.0",
79+
"rollup-plugin-replace": "^2.2.0",
7780
"rollup-plugin-uglify": "^6.0.2",
78-
"typescript": "^3.3.3333"
81+
"typescript": "^3.4.5"
7982
},
8083
"peerDependencies": {
8184
"final-form": ">=4.0.0",
8285
"final-form-arrays": ">=1.0.4",
83-
"react-final-form": "^4.0.0",
86+
"react-final-form": "^6.0.0",
8487
"prop-types": "^15.6.0",
85-
"react": "^16.3.0"
88+
"react": "^16.8.0"
8689
},
8790
"jest": {
8891
"watchPlugins": [
@@ -114,7 +117,6 @@
114117
}
115118
],
116119
"dependencies": {
117-
"@babel/runtime": "^7.3.4",
118-
"react-lifecycles-compat": "^3.0.4"
120+
"@babel/runtime": "^7.4.5"
119121
}
120122
}

‎src/FieldArray.d.test.tsx‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,11 @@ const basic = () => (
1616
>
1717
{({
1818
handleSubmit,
19-
mutators: { push, pop }, // injected from final-form-arrays above
19+
form: {
20+
mutators: { push, pop }, // injected from final-form-arrays above
21+
reset
22+
},
2023
pristine,
21-
reset,
2224
submitting,
2325
values
2426
}) => {

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /