Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

182
Visualizações
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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda