You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The following code snippet is part of what I’ve been working on. I created a schema for validation and added it to the validationSchema prop in Formik. However, after doing so, the console.log(values) in the onSubmit handler is no longer being logged.
Does using validationSchema prevent console.log(values) from being logged, or is there an issue with my schema?
I wrote inputs those are valid but onSubmit didn't work.
Here’s the code:
<FormikinitialValues={initialValues}// validationSchema={schema}onSubmit={(values)=>console.log(values)}><Form><Box><CommonFormname="ticketName"title="Ticket Name"placeholder="Enter the event ticket name"isRequired/><CommonFormname="supportContact"title="Contact Person"placeholder="Enter a contact that can quickly respond to inquiries"isRequired/><Boxsx={{display: 'flex',justifyContent: 'flex-end',alignItems: 'center',}}><Buttontype="submit">Add Ticket</Button></Box></Box></Form></Formik>
And here’s the schema I’m using in useTicketSettingSchema.ts:
Actually I had deleted useMemo, but it didn't also work.
import{useMemo}from'react';import{number,object,string}from'yup';importtype{TicketSettingType}from'types/event';constINITIAL_VALUE=0;constuseTicketSettingSchema=()=>{constinitialValues: TicketSettingType={ticketName: '',ticketDescription: '',ticketPrice: '',ticketQuantity: INITIAL_VALUE,availableTicketsPerPerson: INITIAL_VALUE,ticketStartDate: '',ticketEndDate: '',supportContact: '',};constschema=useMemo(()=>{returnobject({ticketName: string().required('Please enter the ticket name.'),ticketDescription: string().required('Please enter a description for the ticket.'),ticketPrice: string().required('Please enter the ticket price.').min(4,'The minimum ticket price is 1,000.'),ticketQuantity: number().required('Please enter the quantity of tickets.'),availableTicketsPerPerson: number().required('Please enter the maximum number of tickets per person.',),ticketStartDate: string().required('Please enter the ticket start date.'),ticketEndDate: string().required('Please enter the ticket end date.'),supportContact: string().required('Please provide a contact for inquiries.'),});},[]);return{ initialValues, schema };};export{useTicketSettingSchema};
Can you help me figure out why console.log(values) isn't being logged anymore?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
The following code snippet is part of what I’ve been working on. I created a
schema
for validation and added it to thevalidationSchema
prop inFormik
. However, after doing so, theconsole.log(values)
in theonSubmit
handler is no longer being logged.Does using
validationSchema
preventconsole.log(values)
from being logged, or is there an issue with myschema
?I wrote inputs those are valid but onSubmit didn't work.
Here’s the code:
And here’s the schema I’m using in
useTicketSettingSchema.ts
:Actually I had deleted
useMemo
, but it didn't also work.Can you help me figure out why
console.log(values)
isn't being logged anymore?Beta Was this translation helpful? Give feedback.
All reactions