diff --git a/package-lock.json b/package-lock.json index 5a40c1b4..153c51cf 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3264,11 +3264,11 @@ } }, "final-form": { - "version": "3.1.0", + "version": "4.0.0", "resolved": - "https://registry.npmjs.org/final-form/-/final-form-3.1.0.tgz", + "https://registry.npmjs.org/final-form/-/final-form-4.0.0.tgz", "integrity": - "sha512-Op6NGTPbg9B70tb1u9cbLfbsITT7mrr1cxM62uUlDkww9OOlCtzsAlVXxSHsfnVIeMKD2hD6LxFiO5b43zcTtw==", + "sha512-2GjigAcVeXuyd25fMGuh4OxftxiV/ZpHLdtz2X6dYK5NdYOx+p2sMBARETQ+Q6ZTayvfeQlqRmkAj/SeL88eXQ==", "dev": true }, "find-parent-dir": { diff --git a/package.json b/package.json index 5d6db852..c21084ba 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ "eslint-plugin-import": "^2.8.0", "eslint-plugin-jsx-a11y": "^6.0.2", "eslint-plugin-react": "^7.4.0", - "final-form": "^3.0.0", + "final-form": "^4.0.0", "flow": "^0.2.3", "flow-bin": "^0.61.0", "husky": "^0.14.3", @@ -65,7 +65,7 @@ "rollup-plugin-uglify": "^2.0.1" }, "peerDependencies": { - "final-form": "^3.0.1", + "final-form": "^4.0.0", "prop-types": "^15.6.0", "react": "^15.3.0 || ^16.0.0-0" }, diff --git a/src/Field.js b/src/Field.js index 9b204918..d73d3858 100644 --- a/src/Field.js +++ b/src/Field.js @@ -64,15 +64,12 @@ export default class Field extends React.PureComponent { subscription || all, { isEqual, - validate: this.validate, + getValidator: () => this.props.validate, validateFields } ) } - validate = (value: ?any, allValues: Object) => - this.props.validate && this.props.validate(value, allValues) - notify = (state: FieldState) => this.setState({ state }) componentWillReceiveProps(nextProps: Props) { diff --git a/src/ReactFinalForm.js b/src/ReactFinalForm.js index 1f369788..02a2523b 100644 --- a/src/ReactFinalForm.js +++ b/src/ReactFinalForm.js @@ -17,7 +17,12 @@ import type { import type { FormProps as Props, ReactContext } from './types' import shallowEqual from './shallowEqual' import renderComponent from './renderComponent' -export const version = '2.1.0' +import { version } from './index' + +const versions = { + 'final-form': ffVersion, + 'react-final-form': version +} export const all: FormSubscription = formSubscriptionItems.reduce( (result, key) => { @@ -143,7 +148,8 @@ export default class ReactFinalForm extends React.PureComponent { focus: this.form && this.form.focus, handleSubmit: this.handleSubmit, initialize: this.form && this.form.initialize, - reset: this.form && this.form.reset + reset: this.form && this.form.reset, + __versions: versions }, 'ReactFinalForm' ) diff --git a/src/index.js b/src/index.js index 7b6099a4..bbcff535 100644 --- a/src/index.js +++ b/src/index.js @@ -1,4 +1,5 @@ // @flow export { default as Field } from './Field' -export { default as Form, version } from './ReactFinalForm' +export { default as Form } from './ReactFinalForm' export { default as FormSpy } from './FormSpy' +export const version = '2.1.0'