InputDate - valueChanged - React

Posted by: bmysliwy on 18 February 2022, 4:31 am EST

    • Post Options:
    • Link

    Posted 18 February 2022, 4:31 am EST

    Hello,

    I have a problem with InputDate. When I clicked on ButtonComponent the function set the correct value, but when I selected a date in InputData, event valueChange failed to trigger useEffect.

    dataRange.zip

    Best Regards

  • Posted 22 February 2022, 1:24 am EST

    Hi,

    InputDate control does not change any value unless you have handled the valueChanged and updated a state variable or something which causes the useEffect to run. Since, I was unable to run the file provided, I could not investigate the issue properly.

    If possible, please provide a working sample so that I can assist you accordingly.

    Regards,

    Ashwin

  • Posted 23 February 2022, 9:39 am EST

  • Posted 25 February 2022, 4:45 am EST

    Hi,

    The issue was in the onDateFromChange and onDateToChange methods. The original data (the one used in the state) and the new data (which you were updating in setData) are both were the same. So, the setData method does not update the value and the useEffect callback is not called. You can refer the same in the sample below. The onDateFromChange is updated so that a new value is set and therefore the useEffect callback is called but onDateToChange is the same:

    https://stackblitz.com/edit/react-component-example-7-dhmmn8

    So you need to update your method so that setData receives a new value and the state is updated.

    Regards,

    Ashwin

  • Posted 3 March 2022, 4:00 am EST

    Hi, Thanks for help.

    Regards,

    Bartek

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels