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

492
Visualizações
getting error `malformed calls from JS` when using react-native-community/datetimepicker

I am using react-native-community/datetimepicker to select a date. It works fine when I select a date for the first time. But if I again try to open datepicker then it is giving me error.

Below is my code:

const currentDate = Moment();
const [show, setShow]: any = useState(false);
const [changedDate, setChangedDate] = useState<string | null>(null);

const onChange = (event: any, selectedDate: any) => {
    setShow(Platform.OS === 'ios');
    setDate(currentDate);
    var dateInLocal = selectedDate.toLocaleDateString().replace('/', '-');
    console.log(dateInLocal);
    setChangedDate(dateInLocal);
};

<View>
    <Text>{changedDate}</Text>
        <TouchableOpacity
            onPress={() => {
                setShow(true);
            }}>
            <Text>open</Text>
        </TouchableOpacity>
</View>
{show && (
    <DateTimePicker
        testID="dateTimePicker"
        value={
            changedDate ? new Date(changedDate) : currentDate.toDate()
        }
        mode="date"
        is24Hour={true}
        display="default"
        onChange={onChange}
    />
)}

Works fine when selecting date for time, below is the error which I am getting when I am trying open datepicker for second time:

enter image description here

I am not able to understand what I am doing wrong..please help

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