Skip to content
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

Datepicker calls unexisting function utils.getYearText when using moment? #1471

Closed
paul23-git opened this issue Jan 26, 2020 · 17 comments
Closed
Labels
support Ask on StackOverflow

Comments

@paul23-git
Copy link

paul23-git commented Jan 26, 2020

A GIF or MEME to give some spice of the internet

Environment

Tech Version
@material-ui/pickers 3.2.9
material-ui 4.9.0
React 16.12
Browser chrome
Peer library @date-io/moment: 2.0.1 ; moment: 2.24.0

Steps to reproduce

Just added a simple component containing (can't get more basic than this, I'm even providing a static date just to show the error):

import * as React from 'react';
import DateUtils from "@date-io/moment";
import {MuiPickersUtilsProvider, DatePicker} from "@material-ui/pickers";

function App(props) {
    return (<div>
        <MuiPickersUtilsProvider utils={DateUtils}>
            <DatePicker
                label="Basic example"
                value={new Date()}
                animateYearScrolling
            />
        </MuiPickersUtilsProvider>
    </div>);
}

Expected behavior

Well I expect it to work

Actual behavior

The following (long) error chain (though initial error is probably the best):

Uncaught TypeError: utils.getYearText is not a function
  DatePickerToolbar	
  renderWithHooks	
  mountIndeterminateComponent	
  beginWork$1	
  callCallback	
  invokeGuardedCallbackDev	
  invokeGuardedCallback	
  beginWork$$1	
  performUnitOfWork	
  workLoopSync	
  performSyncWorkOnRoot	
  (anonymous function)	
  unstable_runWithPriority	
  runWithPriority$2	
  flushSyncCallbackQueueImpl	
  flushSyncCallbackQueue	
  discreteUpdates$1	
  discreteUpdates	
  dispatchDiscreteEvent	

Uncaught TypeError: utils.getDayText is not a function
  (anonymous function)	
  Calendar._this.renderDays	
  (anonymous function)	
  Calendar._this.renderWeeks	
  render	
  finishClassComponent	
  updateClassComponent	
  beginWork$1	
  callCallback	
  invokeGuardedCallbackDev	
  invokeGuardedCallback	
  beginWork$$1	
  performUnitOfWork	
  workLoopSync	
  performSyncWorkOnRoot	
  (anonymous function)	
  unstable_runWithPriority	
  runWithPriority$2	
  flushSyncCallbackQueueImpl	
  flushSyncCallbackQueue	
  discreteUpdates$1	
  discreteUpdates	
  dispatchDiscreteEvent	

The above error occurred in the <DatePickerToolbar> component:
    in DatePickerToolbar (created by Picker)
    in div (created by Picker)
    in Picker (created by PickerWithState)
    in div (created by ForwardRef(DialogContent))
    in ForwardRef(DialogContent) (created by WithStyles(ForwardRef(DialogContent)))
    in WithStyles(ForwardRef(DialogContent)) (created by ModalDialog)
    in div (created by ForwardRef(Paper))
    in ForwardRef(Paper) (created by WithStyles(ForwardRef(Paper)))
    in WithStyles(ForwardRef(Paper)) (created by ForwardRef(Dialog))
    in div (created by Transition)
    in Transition (created by ForwardRef(Fade))
    in ForwardRef(Fade) (created by TrapFocus)
    in TrapFocus (created by ForwardRef(Modal))
    in div (created by ForwardRef(Modal))
    in ForwardRef(Portal) (created by ForwardRef(Modal))
    in ForwardRef(Modal) (created by ForwardRef(Dialog))
    in ForwardRef(Dialog) (created by WithStyles(ForwardRef(Dialog)))
    in WithStyles(ForwardRef(Dialog)) (created by ModalDialog)
    in ModalDialog (created by WithStyles(ModalDialog))
    in WithStyles(ModalDialog) (created by ModalWrapper)
    in ModalWrapper (created by Wrapper)
    in Wrapper (created by PickerWithState)
    in PickerWithState (at App.js:63)
    in MuiPickersUtilsProvider (at App.js:62)
    in div (at App.js:61)
    in App (at src/index.js:11)

Consider adding an error boundary to your tree to customize error handling behavior.
Visit https://fb.me/react-error-boundaries to learn more about error boundaries.
  console.<computed>	
  logCapturedError	
  logError	
  update.callback	
  callCallback	
  commitUpdateEffects	
  commitUpdateQueue	
  commitLifeCycles	
  commitLayoutEffects	
  callCallback	
  invokeGuardedCallbackDev	
  invokeGuardedCallback	
  commitRootImpl	
  unstable_runWithPriority	
  runWithPriority$2	
  commitRoot	
  finishSyncRender	
  performSyncWorkOnRoot	
  (anonymous function)	
  unstable_runWithPriority	
  runWithPriority$2	
  flushSyncCallbackQueueImpl	
  flushSyncCallbackQueue	
  discreteUpdates$1	
  discreteUpdates	
  dispatchDiscreteEvent	

The above error occurred in the <Calendar> component:
    in Calendar (created by WithUtils(Calendar))
    in WithUtils(Calendar) (created by WithStyles(WithUtils(Calendar)))
    in WithStyles(WithUtils(Calendar)) (created by Picker)
    in div (created by Picker)
    in div (created by Picker)
    in Picker (created by PickerWithState)
    in div (created by ForwardRef(DialogContent))
    in ForwardRef(DialogContent) (created by WithStyles(ForwardRef(DialogContent)))
    in WithStyles(ForwardRef(DialogContent)) (created by ModalDialog)
    in div (created by ForwardRef(Paper))
    in ForwardRef(Paper) (created by WithStyles(ForwardRef(Paper)))
    in WithStyles(ForwardRef(Paper)) (created by ForwardRef(Dialog))
    in div (created by Transition)
    in Transition (created by ForwardRef(Fade))
    in ForwardRef(Fade) (created by TrapFocus)
    in TrapFocus (created by ForwardRef(Modal))
    in div (created by ForwardRef(Modal))
    in ForwardRef(Portal) (created by ForwardRef(Modal))
    in ForwardRef(Modal) (created by ForwardRef(Dialog))
    in ForwardRef(Dialog) (created by WithStyles(ForwardRef(Dialog)))
    in WithStyles(ForwardRef(Dialog)) (created by ModalDialog)
    in ModalDialog (created by WithStyles(ModalDialog))
    in WithStyles(ModalDialog) (created by ModalWrapper)
    in ModalWrapper (created by Wrapper)
    in Wrapper (created by PickerWithState)
    in PickerWithState (at App.js:63)
    in MuiPickersUtilsProvider (at App.js:62)
    in div (at App.js:61)
    in App (at src/index.js:11)

Consider adding an error boundary to your tree to customize error handling behavior.
Visit https://fb.me/react-error-boundaries to learn more about error boundaries.
  console.<computed>	
  logCapturedError	
  logError	
  update.callback	
  callCallback	
  commitUpdateEffects	
  commitUpdateQueue	
  commitLifeCycles	
  commitLayoutEffects	
  callCallback	
  invokeGuardedCallbackDev	
  invokeGuardedCallback	
  commitRootImpl	
  unstable_runWithPriority	
  runWithPriority$2	
  commitRoot	
  finishSyncRender	
  performSyncWorkOnRoot	
  (anonymous function)	
  unstable_runWithPriority	
  runWithPriority$2	
  flushSyncCallbackQueueImpl	
  flushSyncCallbackQueue	
  discreteUpdates$1	
  discreteUpdates	
  dispatchDiscreteEvent	

Uncaught TypeError: utils.getYearText is not a function
  DatePickerToolbar	
  renderWithHooks	
  mountIndeterminateComponent	
  beginWork$1	
  callCallback	
  invokeGuardedCallbackDev	
  invokeGuardedCallback	
  beginWork$$1	
  performUnitOfWork	
  workLoopSync	
  performSyncWorkOnRoot	
  (anonymous function)	
  unstable_runWithPriority	
  runWithPriority$2	
  flushSyncCallbackQueueImpl	
  flushSyncCallbackQueue	
  discreteUpdates$1	
  discreteUpdates	
  dispatchDiscreteEvent	

Live example

(notice that the error is truncated here).
https://codesandbox.io/s/relaxed-bouman-qu188

@dmtrKovalenko
Copy link
Member

Use date-io v1.x.
This was mentioned everywhere

@GavinThompson
Copy link

@dmtrKovalenko Just a heads up, the readme/installation instructions on github for this project does not reference v1.x

@dmtrKovalenko
Copy link
Member

@GavinThompson thanks, all the time forgetting about readme.

@yanickrochon
Copy link

Will this be fixed at some point? This is seriously annoying every time I update my dependencies. It's like "WTF? What now?" Then I waste an hour tracking back to this issue.

@dmtrKovalenko
Copy link
Member

@yanickrochon This already fixed in v4. Update to v4 to use date-io v2. Or use v3 stable of pickers, but do not update date-io.

Thats it.

@yanickrochon
Copy link

@dmtrKovalenko fair enough. thanks.

@Jesusz0r
Copy link

Jesusz0r commented Jun 1, 2020

I have

    "@date-io/moment": "1.3.13",
    "@material-ui/pickers": "3.2.10",
    "moment": "2.26.0",

and still fails

@oliviertassinari
Copy link
Member

@Jesusz0r Can you reproduce it with @material-ui/pickers@4.0.0-alpha.7? A live reproduction on codesandbox would be perfect.

@Gautam-nagpal
Copy link

Use
"@date-io/moment": "^1.3.9",
"@material-ui/pickers": "3.2.10",
"moment": "2.26.0",
restart the server and it will work fine

@oliviertassinari oliviertassinari added the support Ask on StackOverflow label Jun 7, 2020
@2degreesbroadband
Copy link

Use
"@date-io/moment": "^1.3.9",
"@material-ui/pickers": "3.2.10",
"moment": "2.26.0",
restart the server and it will work fine

Thanks! This worked for me :)

@marcelovicentegc
Copy link

For those who faced this issue while using date-fns, downgrading to "@date-io/date-fns": "^1.3.13" fixes that issue as well.

Libraries:

"@date-io/date-fns": "^1.3.13"
"@material-ui/pickers": "^3.2.10"
"draft-js": "^0.11.7"

@ghost
Copy link

ghost commented Mar 9, 2021

Use
"@date-io/moment": "^1.3.9",
"@material-ui/pickers": "3.2.10",
"moment": "2.26.0",
restart the server and it will work fine

Thanks!!!!! 💯

@simo54
Copy link

simo54 commented Jun 20, 2021

Just for documenting purpouse, the following setup worked for me

"@date-io/moment": "1.3.9",
"moment": "^2.29.1",
"@material-ui/pickers": "^3.3.10",

@stefanpl
Copy link

So the fix here is to use outdated versions of the involved libs? 🤔

How is this closed?

@vhmoura
Copy link

vhmoura commented Sep 13, 2023

I am using:
"@date-io/moment": "^2.17.0",
"@material-ui/pickers": "^3.3.11",
"moment": "^2.29.4",

Still having issues. I can't downgrade unfortunately. How and when this be resolved?

@LukasTy
Copy link
Member

LukasTy commented Sep 13, 2023

Still having issues. I can't downgrade unfortunately. How and when this be resolved?

Sorry, but the mentioned library is no longer maintained for quite some time.
You can find more information here: #2157
Feel free to upgrade to using @mui/x-date-pickers to receive the latest updates and features. 😉

@mahisaajy
Copy link

mahisaajy commented Feb 21, 2024

Use "@date-io/moment": "^1.3.9", "@material-ui/pickers": "3.2.10", "moment": "2.26.0", restart the server and it will work fine

for material ui 4.
choose moment 2.26.0 version , it works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
support Ask on StackOverflow
Projects
None yet
Development

No branches or pull requests