Make it easier to replace Select/Dropdown components #2676
Replies: 2 comments 7 replies
-
Oh I understand what you mean. I’ve found myself writing that casting as "hacky” solution as well. Thinking how to ensure this new behavior to be backward compatible?
|
Beta Was this translation helpful? Give feedback.
-
Hi @mihkeleidast and @gpbl I was finishing writing this comment when @gpbl just posted the previous comment. 😅 I'll post in case it's helpful. I understand the confusion, as the Fortunately, there's another API that I think is exactly what you need for your use case: the I'm reading the docs and it's not clear that the Also, I see that it's not clear how to implement a custom Select dropdown for the |
Beta Was this translation helpful? Give feedback.
-
Currently, Select/Dropdown expect onChange prop to be compatible with a native select, i.e. it expects a native event param. DayPicker component only reads
e.target.value
from that event here: https://github.com/gpbl/react-day-picker/blob/main/src/DayPicker.tsx#L231If I want to replace the native select with a custom select component, say react-select, then most of such custom react select implementations do not provide event as a parameter in onChange, rather they forward only the selected value.
Since DayPicker does not need the actual event parameter, it would help if Dropdown/Select components had a custom onChange prop implementation that only requested the necessary value.
I can work around this by essentially only providing the required event object to the native onChange callback, but it's a bit hacky and not very nice to use:
Beta Was this translation helpful? Give feedback.
All reactions