Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

181
Views
Rendering a new component by adding data to Formik values object

I have a speed dial's icon that, when clicked, should add an accordion item to the accordion list.

Its onClick attribute calls a handleClick function that currently adds an object to formik.values.

The object is added to the values map as expected but the user needs to refresh the screen in order to see the new accordion item.

I guess I'm not properly handling the change of state in the form.

I know formik exposes the handleChange method but I'm not sure if and how it should be used in this scenario.

function AddSpeedDial({formik}) {

    const dialActions = [
        {
            icon: <DinnerDiningIcon />,
            name: 'New Dish',
            handleClick: () => {
                const dishCardsLength = Object.keys(formik.values.dishCards).length;
                formik.values.dishCards[dishCardsLength+1] = {
                    dishName: ''
                }
            }
        }
    ];

    return (
        <Box>
            <SpeedDial>
                {dialActions.map((action) => (
                    <SpeedDialAction
                        key={action.name}
                        icon={action.icon}
                        tooltipTitle={action.name}
                        onClick={action.handleClick}
                    />
                ))}
            </SpeedDial>
        </Box>
    );
}

almost 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!