* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-import { Formik, FormikActions, FormikProps } from 'formik';
+import { Formik, FormikHelpers, FormikProps, FormikValues } from 'formik';
import * as React from 'react';
export type ChildrenProps<V> = Omit<FormikProps<V>, 'handleSubmit'>;
-interface Props<V> {
+interface Props<V extends FormikValues> {
children: (props: ChildrenProps<V>) => React.ReactNode;
initialValues: V;
- isInitialValid?: boolean;
onSubmit: (data: V) => Promise<void>;
validate: (data: V) => { [P in keyof V]?: string } | Promise<{ [P in keyof V]?: string }>;
}
-export default class ValidationForm<V> extends React.Component<Props<V>> {
+export default class ValidationForm<V extends FormikValues> extends React.Component<Props<V>> {
mounted = false;
componentDidMount() {
this.mounted = false;
}
- handleSubmit = (data: V, { setSubmitting }: FormikActions<V>) => {
+ handleSubmit = (data: V, { setSubmitting }: FormikHelpers<V>) => {
const result = this.props.onSubmit(data);
const stopSubmitting = () => {
if (this.mounted) {
return (
<Formik<V>
initialValues={this.props.initialValues}
- isInitialValid={this.props.isInitialValid}
onSubmit={this.handleSubmit}
- validate={this.props.validate}>
+ validate={this.props.validate}
+ validateOnMount={true}>
{({ handleSubmit, ...props }) => (
<form onSubmit={handleSubmit}>{this.props.children(props)}</form>
)}
"field": "foo",
}
}
- isInitialValid={true}
onSubmit={[Function]}
validate={[MockFunction]}
>
Object {
"dirty": false,
"errors": Object {},
+ "getFieldHelpers": [Function],
+ "getFieldMeta": [Function],
+ "getFieldProps": [Function],
"handleBlur": [Function],
"handleChange": [Function],
"handleReset": [Function],
"handleSubmit": [Function],
+ "initialErrors": Object {},
+ "initialStatus": undefined,
+ "initialTouched": Object {},
"initialValues": Object {
"field": "foo",
},
"isValidating": false,
"registerField": [Function],
"resetForm": [Function],
- "setError": [Function],
"setErrors": [Function],
"setFieldError": [Function],
"setFieldTouched": [Function],
"setSubmitting": [Function],
"setTouched": [Function],
"setValues": [Function],
+ "status": undefined,
"submitCount": 0,
"submitForm": [Function],
"touched": Object {},
"unregisterField": [Function],
- "validate": [MockFunction],
"validateField": [Function],
"validateForm": [Function],
"validateOnBlur": true,
"validateOnChange": true,
- "validationSchema": undefined,
+ "validateOnMount": true,
"values": Object {
"field": "foo",
},
eslint-plugin-react: 7.29.4
eslint-plugin-react-hooks: 4.4.0
eslint-plugin-testing-library: 5.2.1
- formik: 1.2.0
+ formik: 2.2.9
fs-extra: 10.0.1
glob: 7.2.0
glob-promise: 4.2.2
languageName: node
linkType: hard
-"asap@npm:~2.0.3":
- version: 2.0.6
- resolution: "asap@npm:2.0.6"
- checksum: b296c92c4b969e973260e47523207cd5769abd27c245a68c26dc7a0fe8053c55bb04360237cb51cab1df52be939da77150ace99ad331fb7fb13b3423ed73ff3d
- languageName: node
- linkType: hard
-
"ast-types-flow@npm:^0.0.7":
version: 0.0.7
resolution: "ast-types-flow@npm:0.0.7"
languageName: node
linkType: hard
-"core-js@npm:^1.0.0":
- version: 1.2.7
- resolution: "core-js@npm:1.2.7"
- checksum: 0b76371bfa98708351cde580f9287e2360d2209920e738ae950ae74ad08639a2e063541020bf666c28778956fc356ed9fe56d962129c88a87a6a4a0612526c75
- languageName: node
- linkType: hard
-
"core-util-is@npm:~1.0.0":
version: 1.0.2
resolution: "core-util-is@npm:1.0.2"
languageName: node
linkType: hard
-"create-react-context@npm:^0.2.2":
- version: 0.2.3
- resolution: "create-react-context@npm:0.2.3"
- dependencies:
- fbjs: ^0.8.0
- gud: ^1.0.0
- peerDependencies:
- prop-types: ^15.0.0
- react: ^0.14.0 || ^15.0.0 || ^16.0.0
- checksum: c48829815c90dc8fcd80a1542c70920fe9a1ba18c5f226de42f2494a82701fc5ca5197a64a412dcf1bf6e54b9ea603a8d14ad38df7870ed798490a505b38ac89
- languageName: node
- linkType: hard
-
"cross-spawn@npm:^7.0.2, cross-spawn@npm:^7.0.3":
version: 7.0.3
resolution: "cross-spawn@npm:7.0.3"
languageName: node
linkType: hard
-"encoding@npm:^0.1.11":
- version: 0.1.12
- resolution: "encoding@npm:0.1.12"
- dependencies:
- iconv-lite: ~0.4.13
- checksum: 96df688a93821e866bea19dd689863b1f9e07ef1c15321dde1fbcb8008ed7c785c48b248c4def01367780d2637c459b8ffa988de9647afe4200b003b1ac369ef
- languageName: node
- linkType: hard
-
"encoding@npm:^0.1.12":
version: 0.1.13
resolution: "encoding@npm:0.1.13"
languageName: node
linkType: hard
-"fbjs@npm:^0.8.0":
- version: 0.8.17
- resolution: "fbjs@npm:0.8.17"
- dependencies:
- core-js: ^1.0.0
- isomorphic-fetch: ^2.1.1
- loose-envify: ^1.0.0
- object-assign: ^4.1.0
- promise: ^7.1.1
- setimmediate: ^1.0.5
- ua-parser-js: ^0.7.18
- checksum: e969aeb175ccf97d8818aab9907a78f253568e0cc1b8762621c5d235bf031419d7e700f16f7711e89dfd1e0fce2b87a05f8a2800f18df0a96258f0780615fd8b
- languageName: node
- linkType: hard
-
"file-entry-cache@npm:^6.0.0":
version: 6.0.1
resolution: "file-entry-cache@npm:6.0.1"
languageName: node
linkType: hard
-"formik@npm:1.2.0":
- version: 1.2.0
- resolution: "formik@npm:1.2.0"
+"formik@npm:2.2.9":
+ version: 2.2.9
+ resolution: "formik@npm:2.2.9"
dependencies:
- create-react-context: ^0.2.2
deepmerge: ^2.1.1
- hoist-non-react-statics: ^2.5.5
- lodash.clonedeep: ^4.5.0
- lodash.topath: 4.5.2
- prop-types: ^15.6.1
- react-fast-compare: ^1.0.0
- tslib: ^1.9.3
- warning: ^3.0.0
+ hoist-non-react-statics: ^3.3.0
+ lodash: ^4.17.21
+ lodash-es: ^4.17.21
+ react-fast-compare: ^2.0.1
+ tiny-warning: ^1.0.2
+ tslib: ^1.10.0
peerDependencies:
- react: ">=15"
- checksum: b377ce8ed1cbea22fe7e5adb6c5a9e15826541084a0c48d7ea2f3527d15b257cb18b74b705e80b7b2a545c7fa2bd057067f8e0e21e5b6385233dcbd585e03c3a
+ react: ">=16.8.0"
+ checksum: f07f80eee8423b4c5560546c48c4093c47530dae7d931a4e0d947d68ae1aab94291b1bf2e99ecaa5854ee50593b415fb5724c624c787338f0577f066009e8812
languageName: node
linkType: hard
languageName: node
linkType: hard
-"gud@npm:^1.0.0":
- version: 1.0.0
- resolution: "gud@npm:1.0.0"
- checksum: 3e2eb37cf794364077c18f036d6aa259c821c7fd188f2b7935cb00d589d82a41e0ebb1be809e1a93679417f62f1ad0513e745c3cf5329596e489aef8c5e5feae
- languageName: node
- linkType: hard
-
"has-bigints@npm:^1.0.1":
version: 1.0.1
resolution: "has-bigints@npm:1.0.1"
languageName: node
linkType: hard
-"hoist-non-react-statics@npm:^2.5.5":
- version: 2.5.5
- resolution: "hoist-non-react-statics@npm:2.5.5"
- checksum: ee2d05e5c7e1398ad84a15b0327f66bd78f38a8e0015e852f954b36434e32eb7e942d5357505020a3a1147f247b165bf1e69d72393e3accab67cafdafeb86230
- languageName: node
- linkType: hard
-
"hoist-non-react-statics@npm:^3.3.0, hoist-non-react-statics@npm:^3.3.1, hoist-non-react-statics@npm:^3.3.2":
version: 3.3.2
resolution: "hoist-non-react-statics@npm:3.3.2"
languageName: node
linkType: hard
-"iconv-lite@npm:0.4.24, iconv-lite@npm:^0.4.4, iconv-lite@npm:~0.4.13":
+"iconv-lite@npm:0.4.24, iconv-lite@npm:^0.4.4":
version: 0.4.24
resolution: "iconv-lite@npm:0.4.24"
dependencies:
languageName: node
linkType: hard
-"is-stream@npm:^1.0.1":
- version: 1.1.0
- resolution: "is-stream@npm:1.1.0"
- checksum: 063c6bec9d5647aa6d42108d4c59723d2bd4ae42135a2d4db6eadbd49b7ea05b750fd69d279e5c7c45cf9da753ad2c00d8978be354d65aa9f6bb434969c6a2ae
- languageName: node
- linkType: hard
-
"is-stream@npm:^2.0.0":
version: 2.0.0
resolution: "is-stream@npm:2.0.0"
languageName: node
linkType: hard
-"isomorphic-fetch@npm:^2.1.1":
- version: 2.2.1
- resolution: "isomorphic-fetch@npm:2.2.1"
- dependencies:
- node-fetch: ^1.0.1
- whatwg-fetch: ">=0.10.0"
- checksum: bb5daa7c3785d6742f4379a81e55b549a469503f7c9bf9411b48592e86632cf5e8fe8ea878dba185c0f33eb7c510c23abdeb55aebfdf5d3c70f031ced68c5424
- languageName: node
- linkType: hard
-
"istanbul-lib-coverage@npm:^3.0.0":
version: 3.0.0
resolution: "istanbul-lib-coverage@npm:3.0.0"
languageName: node
linkType: hard
+"lodash-es@npm:^4.17.21":
+ version: 4.17.21
+ resolution: "lodash-es@npm:4.17.21"
+ checksum: 05cbffad6e2adbb331a4e16fbd826e7faee403a1a04873b82b42c0f22090f280839f85b95393f487c1303c8a3d2a010048bf06151a6cbe03eee4d388fb0a12d2
+ languageName: node
+ linkType: hard
+
"lodash.camelcase@npm:^4.3.0":
version: 4.3.0
resolution: "lodash.camelcase@npm:4.3.0"
languageName: node
linkType: hard
-"lodash.clonedeep@npm:^4.5.0":
- version: 4.5.0
- resolution: "lodash.clonedeep@npm:4.5.0"
- checksum: 92c46f094b064e876a23c97f57f81fbffd5d760bf2d8a1c61d85db6d1e488c66b0384c943abee4f6af7debf5ad4e4282e74ff83177c9e63d8ff081a4837c3489
- languageName: node
- linkType: hard
-
"lodash.escape@npm:^4.0.1":
version: 4.0.1
resolution: "lodash.escape@npm:4.0.1"
languageName: node
linkType: hard
-"lodash.topath@npm:4.5.2":
- version: 4.5.2
- resolution: "lodash.topath@npm:4.5.2"
- checksum: 04583e220f4bb1c4ac0008ff8f46d9cb4ddce0ea1090085790da30a41f4cb1b904d885cb73257fca619fa825cd96f9bb97c67d039635cb76056e18f5e08bfdee
- languageName: node
- linkType: hard
-
"lodash.truncate@npm:^4.4.2":
version: 4.4.2
resolution: "lodash.truncate@npm:4.4.2"
languageName: node
linkType: hard
-"node-fetch@npm:^1.0.1":
- version: 1.7.3
- resolution: "node-fetch@npm:1.7.3"
- dependencies:
- encoding: ^0.1.11
- is-stream: ^1.0.1
- checksum: 3bb0528c05d541316ebe52770d71ee25a6dce334df4231fd55df41a644143e07f068637488c18a5b0c43f05041dbd3346752f9e19b50df50569a802484544d5b
- languageName: node
- linkType: hard
-
"node-gyp@npm:latest":
version: 8.2.0
resolution: "node-gyp@npm:8.2.0"
languageName: node
linkType: hard
-"promise@npm:^7.1.1":
- version: 7.3.1
- resolution: "promise@npm:7.3.1"
- dependencies:
- asap: ~2.0.3
- checksum: 475bb069130179fbd27ed2ab45f26d8862376a137a57314cf53310bdd85cc986a826fd585829be97ebc0aaf10e9d8e68be1bfe5a4a0364144b1f9eedfa940cf1
- languageName: node
- linkType: hard
-
"prompts@npm:^2.0.1":
version: 2.1.0
resolution: "prompts@npm:2.1.0"
languageName: node
linkType: hard
-"prop-types@npm:^15.5.8, prop-types@npm:^15.6.0, prop-types@npm:^15.6.1, prop-types@npm:^15.6.2, prop-types@npm:^15.7.2":
+"prop-types@npm:^15.5.8, prop-types@npm:^15.6.0, prop-types@npm:^15.6.2, prop-types@npm:^15.7.2":
version: 15.7.2
resolution: "prop-types@npm:15.7.2"
dependencies:
languageName: node
linkType: hard
-"react-fast-compare@npm:^1.0.0":
- version: 1.0.0
- resolution: "react-fast-compare@npm:1.0.0"
- checksum: a0fd057c68064b1392b0ed49a7a0d0d95e21eb6e04208ddc5cff245c23b26add9038d5fb57f6706d561c8c22c96eb3ff16738a87573487f7f27f140c131f069e
+"react-fast-compare@npm:^2.0.1":
+ version: 2.0.4
+ resolution: "react-fast-compare@npm:2.0.4"
+ checksum: 06046595f90a4e3e3a56f40a8078c00aa71bdb064ddb98343f577f546aa22e888831fd45f009c93b34707cc842b4c637737e956fd13d6f80607ee92fb9cf9a1c
languageName: node
linkType: hard
languageName: node
linkType: hard
-"setimmediate@npm:^1.0.5":
- version: 1.0.5
- resolution: "setimmediate@npm:1.0.5"
- checksum: c9a6f2c5b51a2dabdc0247db9c46460152ffc62ee139f3157440bd48e7c59425093f42719ac1d7931f054f153e2d26cf37dfeb8da17a794a58198a2705e527fd
- languageName: node
- linkType: hard
-
"shallow-equal@npm:^1.2.1":
version: 1.2.1
resolution: "shallow-equal@npm:1.2.1"
languageName: node
linkType: hard
+"tiny-warning@npm:^1.0.2":
+ version: 1.0.3
+ resolution: "tiny-warning@npm:1.0.3"
+ checksum: da62c4acac565902f0624b123eed6dd3509bc9a8d30c06e017104bedcf5d35810da8ff72864400ad19c5c7806fc0a8323c68baf3e326af7cb7d969f846100d71
+ languageName: node
+ linkType: hard
+
"tlds@npm:^1.203.0":
version: 1.207.0
resolution: "tlds@npm:1.207.0"
languageName: node
linkType: hard
-"tslib@npm:^1.10.0, tslib@npm:^1.9.3":
+"tslib@npm:^1.10.0":
version: 1.14.1
resolution: "tslib@npm:1.14.1"
checksum: dbe628ef87f66691d5d2959b3e41b9ca0045c3ee3c7c7b906cc1e328b39f199bb1ad9e671c39025bd56122ac57dfbf7385a94843b1cc07c60a4db74795829acd
languageName: node
linkType: hard
-"ua-parser-js@npm:^0.7.18":
- version: 0.7.28
- resolution: "ua-parser-js@npm:0.7.28"
- checksum: a7da4ad54527211e878ee016c2ef64efad5c2f5a31277d36c9da93b4c89ecaa64f391ad4cf158ada76a9ad8e53004a950705ff1c2f27a52ca8bfb3f1381c39ff
- languageName: node
- linkType: hard
-
"unbox-primitive@npm:^1.0.1":
version: 1.0.1
resolution: "unbox-primitive@npm:1.0.1"
languageName: node
linkType: hard
-"warning@npm:^3.0.0":
- version: 3.0.0
- resolution: "warning@npm:3.0.0"
- dependencies:
- loose-envify: ^1.0.0
- checksum: c9f99a12803aab81b29858e7dc3415bf98b41baee3a4c3acdeb680d98c47b6e17490f1087dccc54432deed5711a5ce0ebcda2b27e9b5eb054c32ae50acb4419c
- languageName: node
- linkType: hard
-
"warning@npm:^4.0.3":
version: 4.0.3
resolution: "warning@npm:4.0.3"
languageName: node
linkType: hard
-"whatwg-fetch@npm:>=0.10.0":
- version: 3.0.0
- resolution: "whatwg-fetch@npm:3.0.0"
- checksum: dcb90ab919e742d275c32d397d7480f6981da4c1b49961f0d0a2fa6825325b553fee2d793bc38ed85b9bcc8c50de39802440e2480fe40243067b3dab228c52c3
- languageName: node
- linkType: hard
-
"whatwg-mimetype@npm:^2.3.0":
version: 2.3.0
resolution: "whatwg-mimetype@npm:2.3.0"