user5711656
user5711656

Reputation: 3678

Uncaught RangeError: `options.awareOfUnicodeTokens` must be set to `true` to use `YYYY` In date picker

I am using date packer in my demo react project . https://www.npmjs.com/package/react-datepicker Every thing is working fine, but I have one issue whenever I remove one text from date value it gives me this error

Uncaught RangeError: options.awareOfUnicodeTokens must be set to true to use YYYY token; see: https://git.io/fxCyr at throwProtectedError (nk7475yjwl.codesandbox.io/node_modules/react-datepicker/lib/index.js:2211) at parse (nk7475yjwl.codesandbox.io/node_modules/react-datepicker/lib/index.js:5733) at parseDate (nk7475yjwl.codesandbox.io/node_modules/react-datepicker/lib/index.js:5962) at DatePicker._this.handleChange (nk7475yjwl.codesandbox.io/node_modules/react-datepicker/lib/index.js:8536) at HTMLUnknownElement.callCallback (react-dom.development.js:145) at Object.invokeGuardedCallbackDev (react-dom.development.js:195) at invokeGuardedCallback (react-dom.development.js:248) at invokeGuardedCallbackAndCatchFirstError (react-dom.development.js:262) at executeDispatch (react-dom.development.js:593) at executeDispatchesInOrder (react-dom.development.js:615) at executeDispatchesAndRelease (react-dom.development.js:713) at executeDispatchesAndReleaseTopLevel (react-dom.development.js:724) at Array.forEach () at forEachAccumulated (react-dom.development.js:692) at runEventsInBatch (react-dom.development.js:855) at runExtractedEventsInBatch (react-dom.development.js:864) at handleTopLevel (react-dom.development.js:4857) at batchedUpdates$1 (react-dom.development.js:17498) at batchedUpdates (react-dom.development.js:2189) at dispatchEvent (react-dom.development.js:4936) at interactiveUpdates$1 (react-dom.development.js:17553) at interactiveUpdates (react-dom.development.js:2208) at dispatchInteractiveEvent (react-dom.development.js:4913)

Steps to produce bug

  1. Run the application.It shows 09-Dec-1998
  2. Try to remove 8 from field or from 1998. it shows above error

here is my code

https://codesandbox.io/s/nk7475yjwl

git link https://github.com/Hacker0x01/react-datepicker

Upvotes: 2

Views: 4590

Answers (1)

shubham
shubham

Reputation: 277

As it states here , YY and YYYY that represent the local week-numbering year (44, 01, 00, 17) are often confused with yy and yyyy that represent the the calendar year.

Try Replacing dd-MMM-YYYY with dd-MMM-yyyy

Upvotes: 7

Related Questions