Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Field Formik lifecycle, Field child hasn't the same props of Parent Formik #1381

Closed
ivan57376 opened this issue Mar 14, 2019 · 1 comment

Comments

Projects
None yet
3 participants
@ivan57376
Copy link

commented Mar 14, 2019

Question

I have a parent component with Formik

//Component Parent

< Formik
        validationSchema={validationSchema}
        render={({ props }) => (
	//… more code 
	<ChildrenComponent props={props} />
)}
 />

//Component Children

import ExternalLib from "external_lib";
function ChildrenComponent ({classes, ...props}) {
	<ExternalLib
          catalogos={state.nacionalidades}
          classes={classes}
          name={"Applicant.TypeOfPerson.Nationality"}
          label={"Nacionalidades"}
          setFieldValue={props.setFieldValue}
      />
}

External Library

This external lib will have the functionality of an autocomplete text to find the Nationalities, Countries, etc.

export default class ExternalLib extends Component {
//…more code
return (
       <div ref={this.divWidth}>
                <Formik> // The lifecycle of this Formik is different than TransactForm for that reason 
                                 //my  Field  called "Applicant.TypeOfPerson.Nationality" doesn’t save the 
                                 //value unless if I use the registerField of this Formik and do the same with 
                                 //the props.registerField from parent Formik. And the 
                                  //validationSchema from Formik parent doesn’t work with this field for the 
                                  //same reason (the lifecycle of this Formik is different than Formik parent).
                                 //Is there a way to pass the Formik props Parent in the Formik of this 
                                //library?
           	<Field
name={this.props.name} // the props.name is  //__"Applicant.TypeOfPerson.Nationality” sent by the children component
            type="text"
            label={this.props.label}
            fullWidth
            component={TextField}
            autoComplete="off"
            required
            onKeyUp={this.onKeyUp}
            InputProps={{
              onBlur:this.onBlur,
              classes: {
                  input: "Field-fontFamily",
                }
            }}
          />
        </Formik>
        {suggestionsListComponent}
      </div>
    );
}

Formik version 1.4.2

@stale stale bot added the stale label May 13, 2019

@clemens-tolboom

This comment has been minimized.

Copy link
Contributor

commented May 17, 2019

What is the question?

And have you heard from react-autocomplete Example

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.