Closed Dashue closed 4 years ago
Thanks, yeah it is a problem. Fix is only add the same wrapping with withDateAdapterProp
as for usual picker https://github.com/mui-org/material-ui-pickers/blob/7bed283699ef768936a3ec7c5dc89571492dddd4/lib/src/Picker/makePickerWithState.tsx#L140
Working reproduction: https://codesandbox.io/s/daterangepicker-momentdateadapter-yhe25?file=/src/index.tsx
@Dashue Side question, what's your motivation for using the dateAdapter
prop instead of the LocalizationProvivder
? Thanks!
@dmtrKovalenko wow that was quick! 👍
@oliviertassinari purely personal, just needed to hard-code something and lack of exposure to providers made dateAdapter = new MomentAdapter({locale:'us-GB'}) feel less magical.
Got it working with a useMomentAdapter hoc, and will either switch everything to use dateAdapter if that gets supported or switch to using LocalizationProvider.
If I wasn't hard-coding things I wouldn't be too sure of how to update the LocalizationProvider value once set?
Thanks for your time guys!
@Dashue If dateAdapter
wasn't available as a prop, would you miss it (forcing you to us LocalizationProvider)?
@oliviertassinari probably not
Fixed as for alpha.9
probably not
@Dashue OK, interesting. I have open #1978 on this matter.
Environment
Steps to reproduce
Expected behavior
Expected to work just like existing Date*Pickers from the library
Actual behavior
Can not find utils in context. It looks like you forgot to wrap your component in LocalizationProvider, or pass dateAdapter prop directly.
Live example
https://codesandbox.io/s/daterangepicker-momentdateadapter-gh7yj?file=/src/index.tsx
For some reason giving different error regarding moment, but if you copy the code to a vscode it does give the reported error.