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

90
Visualizações
Reset Value Problem on Chakra UI's Select Component

I've a problem about Chakra UI's select component. It's somehow doesn't reset their value. Also, when I press the button, Select component doesn't render with new value

https://codesandbox.io/s/compassionate-shockley-f9chz?file=/src/app.tsx:518-863

export const App = (): JSX.Element => {
  const [value, setValue] = React.useState("in");
  const onClick = () => {
    setValue(null);
  };

  console.log("App value", value);

  return (
    <div>
      <Select options={selectionOptions} value={value} />
      <Button onClick={onClick}> click </Button>
    </div>
  );
};

  const [value, setValue] = useState(propValue);

  useEffect(() => {
    if (handleChange) {
      handleChange(value);
    }
  }, [handleChange, value, setValue]);

    <Select
      {...rest}
      value={value}
      onChange={(event) => {
        setValue(event?.target?.value);
      }}
    >
      {options.map(({ value: currentValue, name }, index) => (
        <option key={index} value={currentValue}>
          {name}
        </option>
      ))}
    </Select>

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Bumped into the exact problem. I fixed it by resetting the value with setValue("") instead of setValue(null).

about 4 years ago · Juan Pablo Isaza Relatório
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