Skip to content

Commit 356c12f

Browse files
authored
Final Form v4.0 compatibility (#110)
* Final Form v4.0 compatibility * Upgraded ff dep
1 parent 79da7cf commit 356c12f

File tree

5 files changed

+16
-12
lines changed

5 files changed

+16
-12
lines changed

package-lock.json

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

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
"eslint-plugin-import": "^2.8.0",
4343
"eslint-plugin-jsx-a11y": "^6.0.2",
4444
"eslint-plugin-react": "^7.4.0",
45-
"final-form": "^3.0.0",
45+
"final-form": "^4.0.0",
4646
"flow": "^0.2.3",
4747
"flow-bin": "^0.61.0",
4848
"husky": "^0.14.3",
@@ -65,7 +65,7 @@
6565
"rollup-plugin-uglify": "^2.0.1"
6666
},
6767
"peerDependencies": {
68-
"final-form": "^3.0.1",
68+
"final-form": "^4.0.0",
6969
"prop-types": "^15.6.0",
7070
"react": "^15.3.0 || ^16.0.0-0"
7171
},

src/Field.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,15 +64,12 @@ export default class Field extends React.PureComponent<Props, State> {
6464
subscription || all,
6565
{
6666
isEqual,
67-
validate: this.validate,
67+
getValidator: () => this.props.validate,
6868
validateFields
6969
}
7070
)
7171
}
7272

73-
validate = (value: ?any, allValues: Object) =>
74-
this.props.validate && this.props.validate(value, allValues)
75-
7673
notify = (state: FieldState) => this.setState({ state })
7774

7875
componentWillReceiveProps(nextProps: Props) {

src/ReactFinalForm.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,12 @@ import type {
1717
import type { FormProps as Props, ReactContext } from './types'
1818
import shallowEqual from './shallowEqual'
1919
import renderComponent from './renderComponent'
20-
export const version = '2.1.0'
20+
import { version } from './index'
21+
22+
const versions = {
23+
'final-form': ffVersion,
24+
'react-final-form': version
25+
}
2126

2227
export const all: FormSubscription = formSubscriptionItems.reduce(
2328
(result, key) => {
@@ -143,7 +148,8 @@ export default class ReactFinalForm extends React.PureComponent<Props, State> {
143148
focus: this.form && this.form.focus,
144149
handleSubmit: this.handleSubmit,
145150
initialize: this.form && this.form.initialize,
146-
reset: this.form && this.form.reset
151+
reset: this.form && this.form.reset,
152+
__versions: versions
147153
},
148154
'ReactFinalForm'
149155
)

src/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// @flow
22
export { default as Field } from './Field'
3-
export { default as Form, version } from './ReactFinalForm'
3+
export { default as Form } from './ReactFinalForm'
44
export { default as FormSpy } from './FormSpy'
5+
export const version = '2.1.0'

0 commit comments

Comments
 (0)