afialapis / reactstrap-date-picker

A Reactstrap based, zero dependencies, date picker
MIT License
12 stars 6 forks source link

How to import #14

Closed redefinitionof closed 3 years ago

redefinitionof commented 3 years ago

In your documentation you use: var DatePicker = require("reactstrap-date-picker");

I like to use import in React. When I use import {DatePicker } from 'reactstrap-date-picker'; It can't find DatePicker.

It works when I use: import * as DatePicker from "reactstrap-date-picker";

But then I see a warning in Visual Studio Code: Could not find a declaration file for module 'reactstrap-date-picker'. 'c:/Users/\<username>/node/\<myApp>/node_modules/reactstrap-date-picker/lib/index.js' implicitly has an 'any' type. Try npm i --save-dev @types/reactstrap-date-picker if it exists or add a new declaration (.d.ts) file containing declare module 'reactstrap-date-picker';ts(7016)

Why doesn't this work like a regular react component? How to make it work without errors/warnings?

afialapis commented 3 years ago

Hi,

it is a regular React component. Your issues are not reactstrap-date-picker related.

import DatePicker from 'reactstrap-date-picker'; 
redefinitionof commented 3 years ago

The following now both work, but both give the intellisense? warning as described in original question (grey underline text that on hover show a pop-up). Code seems to work though. import DatePicker from 'reactstrap-date-picker'; import * as DatePicker from 'reactstrap-date-picker';

The problem is not reported anywhere else. It seems to also be reported for other items. (for example: import { Multiselect } from 'multiselect-react-dropdown';) I ignore it.