Bug: defaultSelected doesn't update if the value changes after the first render
markcnunes opened this issue · comments
Bug description
defaultSelected from useInput doesn't update if the value changes after the first render.
This is an issue if the data is being fetched because it starts as undefined and finishes as a date but useInput doesn't update the defaultSelected.
To reproduce
https://codesandbox.io/s/error-useinput-from-react-day-picker-hlspx8
Steps
- Initiate useInput with defaultSelected as undefined
- Change defaultSelected to a Date
Expected behavior
It would make sense if useInput allowed defaultSelected to be modified.
Screenshots
If applicable, add screenshots to help explain your problem.
Additional context
The input field is undefined if the value changes after the first render
It works fine when the date is provided in the first render
I am currently having to overwrite the value for the input tag to be able to allow the input to display the right value after the first render.
<Input
{...inputProps}
value={value ? new Date(value) : undefined}
I am facing the same issue and would love to see a resolution.