Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const formikEnhancer = withFormik({
- mapPropsToValues: props => ({
- firstName: props.firstName || '',
- ...
- }),
- validationSchema: yup.object().shape({
- firstName: yup.string().required('Please enter your first name'),
- ...
- }),
- handleSubmit: (values, formikBag) => {
- console.log('test');
- }
- },
- });
- const BusinessFundingForm = ({
- values,
- isSubmitting,
- errors,
- handleBlur,
- handleChange,
- handleSubmit,
- touched,
- data,
- }) => {
- return (
- <Form className="form" id="form-id">
- <Row>
- <Col xs={12} sm={6}>
- <InputField
- id="first-name"
- type="text"
- name="firstName"
- value={values.firstName}
- onChange={handleChange}
- onBlur={handleBlur}
- placeholder="First Name"
- label="First Name"
- />
- {errors.firstName &&
- touched.firstName && <Error>{errors.firstName}</Error>}
- </Col>
- ...
- </Row>
- <Row>
- <ButtonWrapper>
- <Button
- type="submit"
- tall
- onClick={handleSubmit}
- varianttype={
- isSubmitting ||
- (!!errors.firstName ||
- formHelpers.isEmpty(values.firstName))
- ? 'disabled'
- : 'outline'
- }
- disabled={
- isSubmitting ||
- (!!errors.firstName ||
- formHelpers.isEmpty(values.firstName))
- }
- text="Submit →"
- />
- </ButtonWrapper>
- </Row>
- </Form>
- </FormGrid>
- </Element>
- );
- };
- export default formikEnhancer(BusinessFundingForm);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement