formik

Using react-input-mask with formik and formik-antd

馋奶兔 提交于 2019-12-11 07:46:35
问题 I'm using formik with @jbuschke/formik-antd . I need to apply a mask +7 (___) ___-__-__ to an input, so I would like to use react-input-mask . At the same time I need to parse the value and remove symbols except + and digits, so I handle onChange and setFieldValue myself. I can get changedValue in the console log, but on submit I'm getting the initial value, not the changed one. Here is my code and the demo: const CustomInput = props => ( <InputMask {...props}>{inputProps => <Input {..

Using setFieldValue onSubmit in Formik

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-11 06:35:41
问题 I'm using formik with @jbuschke/formik-antd and react-input-mask . I have a mask +7 (___) ___-__-__ applied to one of the inputs and I need to parse it onSubmit to remove unnecessary symbols. I've defined a const changedValue , which is then used in setFieldValue , but I get the following error: Invariant Violation Maximum update depth exceeded. This can happen when a component repeatedly calls setState inside componentWillUpdate or componentDidUpdate. React limits the number of nested

React Formik bind the external button click with onSubmit function in <Formik>

别说谁变了你拦得住时间么 提交于 2019-12-11 03:42:53
问题 I'm trying to submit the form by using the external buttons which are located outside of <Form> or <Formik> tags As shown in the following screenshot, my button is in Bootstrap > Modal Footer section and they are outside of form tag. I'm trying to submit the form when the user clicks on the Submit button. Please see the similar code as the following. I uploaded it onto CodeSandbox. function App() { return ( <div className="App"> <Formik initialValues={{ date: '10/03/2019', workoutType:

Formik Element type is invalid

半城伤御伤魂 提交于 2019-12-11 01:57:29
问题 Formik I am new to formik and start using it every time i start learning i got this issue Uncaught Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object. I am unable to locate error cause this is my code // here is Login.js file import React, { Component } from "react"; import { Row, Col, Button } from "react-bootstrap"; import validator from "validator"; import { withFormik, Form, Field } from 'formik';

How can I fire a function in headerRight using Formik?

青春壹個敷衍的年華 提交于 2019-12-10 16:38:55
问题 I'm new to react-native and formik and I encountered this problem that I'm trying to build up. How can I fire a function in headerRight using Formik? I have updateCorporation function that will do fire api, and formik will do the job to fire this function and after I press the Update button, but the results are undefined I didn`t understand why its happening. File_1.js const CorporationContainer = (props) => { const { navigation, } = props; const updateCorporation = (values) => { // do patch

How to run setSubmitting() outside the submit handler?

爱⌒轻易说出口 提交于 2019-12-09 09:28:16
问题 I'm trying to implement the approach described on https://www.youtube.com/watch?v=5gl3cCB_26M, where all Redux actions are just plain objects (as they were meant to be) and API calls are done by middlewares. By doing this, the dispatched actions are no longer thunks and can't return a Promise . So I won't be able to use Formik's setSubmitting (to set the isSubmitting flag to false ) inside the submit handler, like the code samples on Formik docs and other tutorials I've found. I've solved the

React | How to Pass FormikProps one Component Up

穿精又带淫゛_ 提交于 2019-12-08 07:53:37
问题 I am trying to pass values and props , that formik needs 1 component up. I am using various little components for some forms, and I am passing them in a complex component that needs to pass them down to each individual render when called. Basically all the FormikProps. Here is one such component. import React, { Fragment } from 'react'; import debounce from 'debounce-promise'; import classNames from 'classnames'; import { Field, FormikProps, ErrorMessage } from 'formik'; import Asterisk from

How to properly use Formik's setError method? (React library)

不羁的心 提交于 2019-12-06 19:09:13
问题 I am using React communicating with a backend. Now trying to properly implement Formik (Form library). Main question: How do I properly use Formik's setError method? Client side validation errors show properly, but now I am trying to set/show the backend validation errors, which are returned with a response with status code 400. Link to the docs on the method I am trying to use I am using this method in the method named handle400Error in the code below. My React (and Formik) code: import

React | How to Pass FormikProps one Component Up

核能气质少年 提交于 2019-12-06 15:55:47
I am trying to pass values and props , that formik needs 1 component up. I am using various little components for some forms, and I am passing them in a complex component that needs to pass them down to each individual render when called. Basically all the FormikProps. Here is one such component. import React, { Fragment } from 'react'; import debounce from 'debounce-promise'; import classNames from 'classnames'; import { Field, FormikProps, ErrorMessage } from 'formik'; import Asterisk from 'shared/common/components/element/Asterisk'; import { validateUsername } from '../../utils/index';

How to properly use Formik's setError method? (React library)

南笙酒味 提交于 2019-12-04 23:19:18
I am using React communicating with a backend. Now trying to properly implement Formik (Form library). Main question: How do I properly use Formik's setError method? Client side validation errors show properly, but now I am trying to set/show the backend validation errors, which are returned with a response with status code 400. Link to the docs on the method I am trying to use I am using this method in the method named handle400Error in the code below. My React (and Formik) code: import React, { Component } from "react"; import axios from "axios"; import { Formik } from "formik"; import * as