question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Date picker documentation needs to be updated

See original GitHub issue

@material-ui/core”: “^4.4.0”, “@material-ui/icons”: “^4.2.1”, “@material-ui/pickers”: “^3.2.2”, “react”: “^16.9.0”, “react-dom”: “^16.9.0”, “react-router-dom”: “^5.0.1”, “react-scripts”: “3.1.1”, “typescript”: “^3.6.2”

Steps to reproduce

The documentation for the date picker doesn’t work and the three closed issues I reviewed for the error don’t resolve the problem for me. I’m unsure what the actual fix is for this.

The documentation is using import DateFnsUtils from '@date-io/date-fns';. If I use the current version of 1.3.11, I get the Can't resolve 'date-fns/addDays' error mentioned below.

This issue says to use date-fns version 2.x. So I installed "date-fns": "^2.2.1" and imported it as import * as DateFnsUtils from 'date-fns';. In doing so I get the error: Cannot find module '@date-io/core/IUtils'.

This issue says to use date-fns@1.30.1. So I installed that version. I get the same Cannot find module '@date-io/core/IUtils' error.

At this point I decided to install "@date-io/core": "^1.3.11". Running with that, I get the error: Cannot find module '@date-io/type'. I attempted to install that and the package doesn’t appear to exist.

I also tried installing "date-fns": "^2.2.1" with "@date-io/core": "^1.3.11", but I still get the Cannot find module '@date-io/type' error.

[Edit 1] Looking at the type definitions for MuiPickersUtilsProvider; I noticed that’s importing import { IUtils } from '@date-io/core/IUtils';. IUtils has a moment property, so I thought I’d try passing moment in as the MuiPickersUtilsProvider.utils property. I still end up with the Cannot find module '@date-io/type' error.

[Edit 2] I realized I should check out the CodeSandbox for the example. That appears to be working, however when I try to install the same packages it uses, neither @types/date-ioDate-fns nor @types/material-uiPickers appear to exist. No matter what packages I try, I still run into the Cannot find module '@date-io/type'. error.

I’m at a loss here. 😦

Expected behavior

If I follow the documentation I shouldn’t get errors.

Actual behavior

Getting error: Can't resolve 'date-fns/addDays'. Closed issue here.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:3
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
Kizmarcommented, Sep 15, 2019

As a side note: if one or more of these date-fns packages is a requirement of using the date picker, why aren’t they added as dependencies in the @material-ui/pickers package so we don’t have to worry about what we’re supposed to install to pass to the provider (<MuiPickersUtilsProvider utils={DateFnsUtils}>)?

In regards to [Edit 1] in the OP, if it’s not included because you can pass in moment instead, that makes sense. I already had moment installed because I needed good UTC support and it doesn’t appear date-fns format is there yet.

0reactions
dmtrKovalenkocommented, Sep 17, 2019
Read more comments on GitHub >

github_iconTop Results From Across the Web

Methods — bootstrap-datepicker documentation
Update the datepicker with given arguments or the current input value. The arguments can be either an array of strings, an array of...
Read more >
DatePicker | Apple Developer Documentation
Use a DatePicker when you want to provide a view that allows the user to select a calendar date, and optionally a time....
Read more >
Datepicker Widget - jQuery UI API Documentation
An input element that is to be updated with the selected date from the datepicker. Use the altFormat option to change the format...
Read more >
[DatePicker] Manually entering date does not update month in ...
Pressing the Enter updates the year and day on the calendar UI, but the month does not change. It is expected that the...
Read more >
Reset date range selection with new Date Picker Range
Then you need add a local variable of text type that will hold the value of the input widget that you will get...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found