react-datetime-picker icon indicating copy to clipboard operation
react-datetime-picker copied to clipboard

Pass name into onChange handler

Open insivika opened this issue 4 years ago • 1 comments

How do I pass the "name" prop into the onChange handler. It seems to only return the actual date/time which is very limiting.

insivika avatar Sep 12 '19 14:09 insivika

Hi, since React-DateTime-Picker contains multiple input elements to achieve what it's made for, we couldn't use native event handler. I suggest you to curry your onChange function to achieve what you want:

function makeOnChange(name) {
  return function onChange(value) {
    return { name, value };
  }
}

// Usage:
<DateTimePicker onChange={makeOnChange('myName1')} />

wojtekmaj avatar Sep 23 '19 14:09 wojtekmaj

This issue is stale because it has been open 90 days with no activity. Remove stale label or comment or this issue will be closed in 14 days.

github-actions[bot] avatar Jan 16 '23 00:01 github-actions[bot]

This issue was closed because it has been stalled for 14 days with no activity.

github-actions[bot] avatar Feb 06 '23 00:02 github-actions[bot]