Not sure how getDateStr prop is supposed to work.
See original GitHub issueHere is what the documentation says about getDateStr
:
A function to override how to format the date into a String for display, receives a Date instance
Can someone explain me the following behavior?
This works:
<DatePicker
...
format="LL"
/>
This doesn’t work (isn’t getDateStr
supposed to replace format
?):
<DatePicker
...
getDateStr={rawDate => moment(rawDate).format('LL')}
/>
This works (and I can save rawDate
for something else):
<DatePicker
...
format="LL"
getDateStr={rawDate => moment(rawDate).format('LL')}
/>
Issue Analytics
- State:
- Created 5 years ago
- Reactions:4
- Comments:8
Top Results From Across the Web
Why You Should Check Your Prop Regularly - YouTube
Miles "Sonar" Burghoff explains how to quickly change a bass boat prop and why you should regularly check it to keep your motor...
Read more >Boat Propeller Pitch Explained - How To Select the Right Prop
2022 Best Live Bait Rigs → https://bit.ly/jujurigsCAST NETS WE USE → https://bit.ly/2X9EJJjJoin us today in beautiful Biscayne Bay as we ...
Read more >Five Reasons You May Need to Change Your Prop - BoatUS
Choosing the wrong prop or using a damaged prop can cause your boat to perform poorly, increasing fuel consumption or damage your engine...
Read more >Extracting month from DS3231 function rtc.getDateStr()
Hello, Does anyone know if it is possible to extract only the month of the year from ... There is no getDateStr() function...
Read more >How to Find the Right Boat Propeller | West Marine
Four-blade designs work well with boats that are difficult to get on plane, underpowered or used in watersports where top-end speed is not...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Same here. Makes no sense. It seems to suggest that you can work with values in the format property and override getDateStr to only change the text displayed in the field.
But, in the getDateStr, if you return a format different than the one specified in “format” property, it gives “Invalid Date”.
So…what’s the point?
The documentation is really not very clear. In my case the format I want to use for display is
'DD/ MM/YYYY HH:mm'
so I return an object of typemoment()
with this format in all places where I manipulate my date and do not use the DatePickerformat
props:My initial state to date:
In
getDateStr
I use the same format:So on
onDateChange
I change my state with a moment() object with the same format :