-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Provide a simple moment-less API #382
Comments
For posterity here is what my wrapper component looks like:
|
This comment isn't really helping, but wanted to share my thoughts. |
IMO, since a date picker just lets you choose a year, month, and day, its state should just be three JavaScript numbers. The component is just a piece of UI and shouldn't be prescriptive about your data model. It shouldn't require a heavy dependency like |
The more I look at this, the more I think a better solution would be the opposite of 1: Make the core API as simple as possible (but no simpler), and add a wrapper around that which adds moment, timezones, timestamps and any other unnecessary but potentially convenient complexity. |
I used react-datepicker in a previous project and did some PRs. It's a really nice datetime picker. However, the Would love to see |
All open for getting rid of moment. I don't have time to work on that currently, but I'm welcoming PR's to make this simpler. |
Hi, I'd like to give it a shot as part of Hacktoberfest. Making big dependencies optional is always nice, because while I'm sure I'll need such a component at some point I'd definitely search for something else due to Are there requirements beyond 1.) getting rid of I looked a bit over the source and would approach it like this:
Then we can decide how to build the API to use one or the other. Simplest possibility is a separate build? |
Moment was removed in #1527 |
In one of my projects I'm passing dates to server API calls as strings, and I also receive dates back as strings which are stored in redux state. In the spirit of keeping my state clean I keep the strings as the source of truth rather than moment objects; this also makes it possible to pre-generate my state on the server, which would get ugly if it contained moment objects. This led me to write a wrapper datepicker component that would simply translate between strings and moment objects so that they can be passed as props to the datepicker. This got me thinking that maybe we should provide a way of dealing with strings natively in this component. I can think of a couple approaches here:
SimpleDatePicker
seems a little sillysimple
prop -- When set all props (selected
,minDate
, etc, the value passed toonChange
) will be strings formatted according todateFormat
. A little dirtier code-wise; adding a prop to control how other props are handled seems kind of anti-react to meselected
: if a string, everything is a string, and if a moment, everything is a moment. By far the simplest API; dirtier code-wise, and I'm not sure how it should behave whenselected
isnull
What does everyone think?
The text was updated successfully, but these errors were encountered: