Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DayPickerInput.onDayChange wrong type in TypeScript definition? #622

Closed
thomastvedt opened this issue Feb 14, 2018 · 2 comments
Closed

DayPickerInput.onDayChange wrong type in TypeScript definition? #622

thomastvedt opened this issue Feb 14, 2018 · 2 comments
Milestone

Comments

@thomastvedt
Copy link

I'm trying out the DayPickerInput component in TypeScript, but I can't access the modifiers in the onDayChange event. Are the TypeScript typings wrong? Or am I missing something?

From the docs:
http://react-day-picker.js.org/api/DayPickerInput

onDayChange (day: Date, modifiers: Object) ⇒ void
Handler function called when the user types a valid day (according to the format prop) or when a day is clicked on the calendar. If the day is not valid, day and modifiers arguments will be undefined (useful to display validation warnings).

From /types/props.d.ts:
onDayChange?(e: React.FocusEvent<HTMLDivElement>): void;

Should this be instead:
onDayChange?(day: Date | undefined, modifiers: {} | undefined): void;
?

Is there a type for Modifiers btw?

If I try to do this:
<DayPickerInput onDayChange={this.handleDayChange} />

this works:
handleDayChange = (e: any) => { console.log('this works, e is date, not focusevent');}

this should work (?), but does not..:
handleDayChange = (day: Date, modifiers: {} | undefined) => { console.log('error');}

@gpbl gpbl added this to the next patch milestone Feb 23, 2018
@gpbl gpbl added bug and removed TypeScript labels Feb 23, 2018
@gpbl gpbl removed this from the next patch milestone Feb 23, 2018
@gpbl gpbl closed this as completed in 210f253 Feb 25, 2018
@gpbl gpbl added this to the v7.1.0 milestone Mar 5, 2018
@gpbl
Copy link
Owner

gpbl commented Mar 5, 2018

Published as v7.1.0.

@thomastvedt
Copy link
Author

Great! Thank you 🌹

kimamula pushed a commit to kimamula/react-day-picker that referenced this issue Aug 17, 2022
kimamula pushed a commit to kimamula/react-day-picker that referenced this issue Aug 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants