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

491
Views
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
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!