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

Pass event/datepicker info to onChange #473

Closed
georgiosd opened this issue Jun 16, 2018 · 1 comment
Closed

Pass event/datepicker info to onChange #473

georgiosd opened this issue Jun 16, 2018 · 1 comment

Comments

@georgiosd
Copy link

Hi!

Fantastic job, thank you!

Just a suggestion: somehow pass the id/name of the date picker to the onChange so we can wire multiple pickers with one handler.

Thanks
Georgios

@alitaheri
Copy link
Member

Not really feasible since the event could come from various sources of user interaction. (touch, click, keypress, etc... ). However, your issue is unrelated. you could just simply use a Higher Order Function to achieve the same result in a much more readable and predictable way:

createHandleDataChange = (id) => (date) => {
 // Do something with id and date
}


render() {
  return (
    <>
      <DatePicker {/*...*/} onChange={this.createHandleDataChange('my-first-date-picker')} />
      <DatePicker {/*...*/} onChange={this.createHandleDataChange('my-second-date-picker')} />
      <DatePicker {/*...*/} onChange={this.createHandleDataChange('my-third-date-picker')} />
    </>
  );
}

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