We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

DateTimePicker value not updated when component updated

Hi,

I'm rendering DateTimePickerComponent with a given value.
When my component updated with different value, the value on the control stays the same.

Please let me know what I'm doing wrong, sounds like very simple scenario to me. 

Thanks,
Asaf

Code Example (example also available here - https://stackblitz.com/edit/react-7tziri ) 

import React, { Component } from "react";
import moment from "moment";
import { DateTimePickerComponent } from "@syncfusion/ej2-react-calendars";
import "@syncfusion/ej2/material.css";


export default function App() {
  return (
    <div>
      <DateWrapper />
    </div>
  );
}

class DateWrapper extends Component {
  constructor(params) {
    super(params);

    setInterval(() => {
      this.setState({
        date: moment(this.state.date)
          .add(1, "days")
          .toDate()
      });
      console.log("new date:" + this.state.date.toString());
    }, 2000);

    this.state = {
      date: moment().toDate()
    };
  }

  render() {
    return <DateComponent date={this.state.date} />;
  }
}

const DateComponent = ({ date }) => <DateTimePickerComponent value={date} />;


4 Replies 1 reply marked as answer

AB Asaf benyamin October 25, 2020 05:28 AM UTC

Hi,

Has anyone facing this issue too?
I've managed to reproduce the issue when modifying the official datetimepicker exmple - https://react-ef457t-mo2axf.stackblitz.io/

The only workaround I've found so far was manually managing the key prop, which is not the way it should be.

Please if someone can assist.

Thanks



SP Sureshkumar P Syncfusion Team October 26, 2020 12:24 PM UTC

Hi Asaf,  
  
Thank you for contacting Syncfusion Support.  
  
We confirmed the reported issue "Each child in a list should have a unique "key" prop" as a bug in our end and the fix will be available in our upcoming patch release. You can track the status of the bug in the below feedback link from below.      
  
  
Regards,  
Sureshkumar P 



AB Asaf benyamin October 26, 2020 06:12 PM UTC

Hi,

Thanks for your response.
My question was not about "Each child in a list should have a unique "key" prop"
which is a different issue.

My question is about updating the datetimepicker.

Are those 2 issues related?

Thanks



SP Sureshkumar P Syncfusion Team October 30, 2020 07:30 AM UTC

Hi Asaf, 
 
Thanks for your update. 
 
We have already considered this reported scenario and logged this requirement as feature request at our end. We will implement this feature in volume 3 sp1 release which is expected to be rolled out on November 5th,2020. We appreciate your patience until then.     
   
 
Regards, 
Sureshkumar P 


Marked as answer
Loader.
Live Chat Icon For mobile
Up arrow icon