react-datepicker icon indicating copy to clipboard operation
react-datepicker copied to clipboard

onBlur callbacks in console example code has typo's

Open sizeight opened this issue 8 years ago • 4 comments

Expected behavior

The example code for onBlur callbacks in console has some typos that are confusing when trying to understand the example.

handleOnBlur: function (date) { // <- date shoulde be event
    const date = new Date(event.target.value);
    if (isValid(date)) {
      console.log("selected date: %s", format(date, "dd/MM/yyyy")); // <- Maybe include 'Valid' in string
    } else {
      console.log("selected date: %s", event.target.value); // <- Maybe include 'Invalid' in string
    }
};'} // <- Remove unwanted '}

Actual behavior

Should be

handleOnBlur: function (event) {
    const date = new Date(event.target.value);
    if (isValid(date)) {
      console.log("Valid selected date: %s", format(date, "dd/MM/yyyy"));
    } else {
      console.log("Invalid selected date: %s", event.target.value);
    }
};

sizeight avatar Nov 21 '18 08:11 sizeight

Would appreciate if you can submit a PR for this.

martijnrusschen avatar Nov 21 '18 09:11 martijnrusschen

@martijnrusschen Will try to get round to it.

sizeight avatar Nov 21 '18 10:11 sizeight

This was fixed in #1548.

Darrken avatar Nov 21 '18 16:11 Darrken

Awesome, thanks!

martijnrusschen avatar Nov 21 '18 16:11 martijnrusschen