Rudeg / react-input-calendar

http://rudeg.github.io/react-input-calendar/
MIT License
139 stars 94 forks source link

inputValue causing component to go from controlled to uncontrolled #101

Closed famu1hundred closed 8 years ago

famu1hundred commented 8 years ago

When using the version 0.3.11 with react 15.3, I see the following warning in the develop console: Warning: value prop on input should not be null. Consider using the empty string to clear the component or undefined for uncontrolled components.

What is happening is when first rendering the Calendar, the inputValue is undefined. If you select an invalid date, like 'abc', with strictDateParsing the inputValue changes to null and thus when the component is re-rendered, its now in a controlled state. If I modify the index.js to set the default state of inputValue to an empty string...and anywhere else in the code where an invalid date causes a state change to inputValue to be an empty string instead of null...all problems go away.

This was found because, in my implementation, we wanted to clear the input field value if the date is invalid instead of showing what the user entered, like 'abc'.

priyanr commented 8 years ago

i faced the issue , i think this will fix https://github.com/Rudeg/react-input-calendar/pull/102

kjs3 commented 8 years ago

This issue is resolved for me. I think this can be closed.

Rudeg commented 8 years ago

Thanks!