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

307
Visualizações
How to Reset react-native-picker-select on form submit using formik inReact Native?

I am using Formik and react-native-picker-select, I can reset text and number fields after submission but can not able to reset picker-select. How can I achieve it?

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

0

The reseted value for react-native-picker-select is null.

So you need to create a state that stores the current value of the picker and when you want to reset it, set it to null.

The secret here is set the value={state variable} parameter, so that the picker updates every time that the state is also updated. The state variable is updated with onValueChange.

const Component = () => {
  const [pickerValue, setPickerValue] = useState(null);

  return (
    <>
      <RNPickerSelect
        onValueChange={v => setPickerValue(v)}
        value={pickerValue}
        items={[
          {label: 'Football', value: 'football'},
          {label: 'Baseball', value: 'baseball'},
          {label: 'Hockey', value: 'hockey'},
        ]}
      />

      <TouchableOpacity onPress={() => setPickerValue(null)}>
        <Text>Submit</Text>
      </TouchableOpacity>
    </>
  );
};
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