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

getStartOfMonth is not a function error #26

Open
bawpcwpn opened this issue Feb 13, 2019 · 1 comment
Open

getStartOfMonth is not a function error #26

bawpcwpn opened this issue Feb 13, 2019 · 1 comment

Comments

@bawpcwpn
Copy link

bawpcwpn commented Feb 13, 2019

Hi!

Trying to use this with react-admin 2.7.1 and when using a I get the following error when clicking on the field:

TypeError: _this.props.utils.getStartOfMonth is not a function

The versions for my other packages are:
"@date-io/date-fns": "^1.1.0",
"date-fns": "^2.0.0-alpha.27",

If I can provide any other info, please let me know!

@cmf2903
Copy link

cmf2903 commented Feb 18, 2019

Solved it by adding below line after importing the utils import DateFnsUtils from '@date-io/date-fns'

DateFnsUtils.prototype.getStartOfMonth = DateFnsUtils.prototype.startOfMonth

Ref: mui/material-ui-pickers#877 (comment)

And when getting an error related to awareOfUnicodeTokens need to set to true, need change the format from DD and YYYY to dd and yyyy respectively.

Ref: https://blog.date-fns.org/post/unicode-tokens-in-date-fns-v2-sreatyki91jg

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

No branches or pull requests

2 participants