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.

Error import/default when importing react-date-picker

See original GitHub issue

I want to import “react-date-picker” (https://github.com/wojtekmaj/react-date-picker) in a Typescript source file:

import DatePicker from 'react-date-picker'

When I use “eslint-import-resolver-typescript” by applying this snippet

settings: {
  "import/resolver": {
    "typescript": {}
  }
}

in .eslintrc.js there’s an error 1:8 error No default export found in imported module "react-date-picker" import/default

However, “react-date-picker” contains this default:

declare module "react-date-picker" {
  export default function DatePicker(props: DatePickerProps): JSX.Element;
...

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:14 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
jeffrsoncommented, May 5, 2021

Okay, thanks! So I won’t report it against the resolver for the time being.

0reactions
JounQincommented, Jul 19, 2022

@jeffrson

The typings file in react-date-picker can be omitted as

import { CalendarProps } from "react-calendar";

export default function DatePicker(props: DatePickerProps): JSX.Element;

export interface DatePickerProps extends CalendarProps {
  autoFocus?: boolean;
  calendarAriaLabel?: string;
  calendarClassName?: string | string[];
  calendarIcon?: JSX.Element | null;
  className?: string | string[];
  clearAriaLabel?: string;
  clearIcon?: JSX.Element | null;
  closeCalendar?: boolean;
  dayAriaLabel?: string;
  dayPlaceholder?: string;
  disabled?: boolean;
  disableCalendar?: boolean;
  format?: string;
  isOpen?: boolean;
  monthAriaLabel?: string;
  monthPlaceholder?: string;
  name?: string;
  nativeInputAriaLabel?: string;
  onCalendarClose?: () => void;
  onCalendarOpen?: () => void;
  openCalendarOnFocus?: boolean;
  portalContainer?: HTMLElement;
  required?: boolean;
  showLeadingZeros?: boolean;
  yearAriaLabel?: string;
  yearPlaceholder?: string;
}

The declare module block is just redundant as its own declaration file.

I’ve raised https://github.com/wojtekmaj/react-date-picker/pull/419 to cleanup.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Webpack error importing Date picker · Issue #546 - GitHub
Hi, I'm new in webpack and React. When trying to use this library with webpack could not import it. this is the error:...
Read more >
Attempted import error: 'DatePicker' is not exported from 'gestalt'
I want to use DatePicker in gestalt but getting errors like the title. Everything else provided gestalt such as TextField, Box, ...
Read more >
Upgraded to TS 4.6, getting error for __importDefault - Reddit
Just add this __importDefault definition to webpack, and this will start working, but I am unable to understand, why is is importing this ......
Read more >
@y0c/react-datepicker - npm
Start using @y0c/react-datepicker in your project by running `npm i ... import Calendar Component import React, { Component } from 'react'; ...
Read more >
Adding Styles to the React Date Picker - DevCamp
In this video we're going to start by styling our date picker. So let's go back to the react date picker. And you'll...
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