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

Multiple button needs reference in fieldArray onClick={() => fields.push({})} #4764

Open
udayanss opened this issue Jun 29, 2022 · 0 comments

Comments

@udayanss
Copy link

Hello , I need two different sets of field while clicking on two differrent buttons, onClick={() => fields.push({})}, how do i send parameters for each field so that i can use if else in my return li, any luck on this

renderProductField = ({ fields, meta: { error, submitFailed } }) => (


    <li className="text-center" style={{ paddingTop: 0 }}>
    <button
    className="text-primaryLight cursor-pointer button mx-2"
    onClick={() => fields.push({})}
    // onClick={(e) => this.buttonClickSection(e,fields, 'product')}
    >
    Add Product Section

    <button
    className="text-primaryLight cursor-pointer button mx-2"
    // onClick={() => fields.push({section:'banner'})}
    onClick={() => fields.push({})}
    // onClick={(e) => this.buttonClickSection(e,fields, 'banner')}
    >
    Add Banner Section

    {submitFailed && error && {error}}

       {fields.map((arrvalues, index) => {
    
          return (
            <li
              key={index}
              className="home-section-block"
              style={{
                border: "1px solid gray",
                borderRadius: "15px",
                marginTop: "15px",
              }}
            >
       
            </li>
          );
        })} 
      </div>
    </ul>
    

    );

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant