formik

stop handleBlur from doing anything

我怕爱的太早我们不能终老 提交于 2021-02-11 05:07:56
问题 In my Formik form, when I click on the search button, a list of items is rendered (UsersFoundList). This list is outside the form and each item in the list has a button of its own. When I click on any of those buttons from the list for the first time, they don't work. Instead, the handleBlur of my form is triggered and since the input field is empty, an error messages starts showing under the input field. So, the button doesn't do what it's supposed to do in the first attempt. I tested the

stop handleBlur from doing anything

笑着哭i 提交于 2021-02-11 05:01:49
问题 In my Formik form, when I click on the search button, a list of items is rendered (UsersFoundList). This list is outside the form and each item in the list has a button of its own. When I click on any of those buttons from the list for the first time, they don't work. Instead, the handleBlur of my form is triggered and since the input field is empty, an error messages starts showing under the input field. So, the button doesn't do what it's supposed to do in the first attempt. I tested the

How to prevent user multiple click submit button error for a login form in react?

吃可爱长大的小学妹 提交于 2021-02-10 14:14:47
问题 I use formik and react-router-dom for my react login management. However, if click the submit button multiple times in a short time, after redirect to home page, there will be an error of "Warning: Can't perform a React state update on an unmounted component. This is a no-op, but it indicates a memory leak in your application. To fix, cancel all subscriptions and asynchronous tasks in the componentWillUnmount method. in SignInForm (created by Route) in Route (at App.js:52)" And the home page

Formik Validation for Native Base Input

五迷三道 提交于 2021-02-09 03:00:42
问题 I am using native base's input field and am trying to validate it using Formik and Yup. However, no validation is happening so far. It doesn't show any errors even if I type alphabets. This code works (without Formik): type EmailRegistrationProps = {}; interface FormValues { friendEmail: string; } type AddFriendEmailPageProps = { toggleShowPage: () => void; showAddFriendEmailPage: boolean; }; export const AddFriendEmailPage: React.FunctionComponent<AddFriendEmailPageProps> = ({ toggleShowPage

Formik Validation for Native Base Input

微笑、不失礼 提交于 2021-02-09 02:57:17
问题 I am using native base's input field and am trying to validate it using Formik and Yup. However, no validation is happening so far. It doesn't show any errors even if I type alphabets. This code works (without Formik): type EmailRegistrationProps = {}; interface FormValues { friendEmail: string; } type AddFriendEmailPageProps = { toggleShowPage: () => void; showAddFriendEmailPage: boolean; }; export const AddFriendEmailPage: React.FunctionComponent<AddFriendEmailPageProps> = ({ toggleShowPage

touched property not being reset

十年热恋 提交于 2021-01-28 20:49:06
问题 I have a Formik form where I take user input input & run a query after submitting. When I click on the search button, a list is rendered. All list items have a button of their own. When I click on the green add button (from the list items) for the first time, the button does not work. Console log's content is not printed. Instead, the onBlur event of the inputField is triggered. However, if I click on the + button again, then it works and prints no. This problem is visible in simulators

Formik 2.0.1 useFormikContext formik values undefined

梦想与她 提交于 2021-01-28 07:35:22
问题 Using useFormikContext in Formik 2.0.1 . Receiving Cannot read property 'values' of undefined when binding formik.values in the form. Thanks in advance!... 回答1: You have to define formik inside the InnerForm() like this: const InnerForm = () => { const formik = useFormikContext<IPerson>() return ( <form> <input name="id" value={formik.values.id} /> <input name="name" value={formik.values.name} /> </form> ); }; 来源: https://stackoverflow.com/questions/58669214/formik-2-0-1-useformikcontext

Displaying Value of setFieldErrors Using ErrorMessage Component in Formik

亡梦爱人 提交于 2020-12-12 11:33:27
问题 See Update Below I have a Login Form Component that I built using Formik that syncs with Firebase Authentication. I have set it up so that I can display errors from Firebase using the setFieldError prop. Here is the relevant sections of the code: export const LoginForm = () => { async function authenticateUser(values, setFieldError) { const { email, password } = values try { await firebase.login(email, password) navigate('/', { replace: true }) } catch (error) { console.log('Authentication

Displaying Value of setFieldErrors Using ErrorMessage Component in Formik

无人久伴 提交于 2020-12-12 11:33:11
问题 See Update Below I have a Login Form Component that I built using Formik that syncs with Firebase Authentication. I have set it up so that I can display errors from Firebase using the setFieldError prop. Here is the relevant sections of the code: export const LoginForm = () => { async function authenticateUser(values, setFieldError) { const { email, password } = values try { await firebase.login(email, password) navigate('/', { replace: true }) } catch (error) { console.log('Authentication

Discarding changes when using Formik with React

Deadly 提交于 2020-12-05 05:43:08
问题 I am using Formik form with React. Whenever the user submits (handleSubmit), I put an option whether or not to discard the change or keep the change. In my render, <Formik initialValues={this.state.experiment} onSubmit={this.handleSubmit} component={formikProps => ( <ExperimentForm {...formikProps} submitText="Save Changes" /> )} /> handleSubmit() handleSubmit(formdata: any, actions: any) { const data = processFormData(formdata); let changes = this.detectChanges(this.state.experiment, data);