IjzerenHein / react-tag-cloud

Create beautiful tag/word clouds using React ☁️
https://react-tag-cloud.stackblitz.io/
MIT License
117 stars 27 forks source link

Could not find a declaration file for module 'react-tag-cloud' #14

Closed hectoraldairah closed 5 years ago

hectoraldairah commented 5 years ago

Hi! I'm trying to use the component in my project with create-react-app. When I install the dependency vs code shows me:

Could not find a declaration file for module 'react-tag-cloud'. '~/node_modules/react-tag-cloud/dist/TagCloud.js' implicitly has an 'any' type. Try npm install @types/react-tag-cloud if it exists or add a new declaration (.d.ts) file containing `declare module 'react-tag-cloud'

React doesn't show me an error but the component is not rendered at all.

What can I do? What is a .d.ts file?

zerobell-lee commented 5 years ago

Same for me. It doesn't work and just render empty div.

CGagnier commented 5 years ago

I have the same error as both of you.

I managed to get it work by including the following classes and include the css file from the example presented in the README.md


<div className='app-outer'>
            <div className='app-inner'>
                    <TagCloud 
                            className='tag-cloud'
                       ...
                   </TagCloud>
           </div>
</div>

with this styling (src)

.app-outer {
    align-items: center; 
    bottom: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    left: 0;
    padding: 20px 0;
    position: absolute;
    right: 0;
    top: 0;
}

.app-inner {
    display: flex;
    flex-direction: column;
    height: 100%;
    max-width: 1000px;
    width: 100%;
}

 .tag-cloud {
    flex: 1;
}

See the complete example here: (Playground on StackBlitz) (source)

I think I could be a good idea to include de css in the module to help the integration.

Hope it help both of you in case you haven't figured the solution already 🙂

IjzerenHein commented 5 years ago

Hi, there are no TypeScript/Flow type definitions available for this project yet. I'll see whether I can add them

IjzerenHein commented 5 years ago

Hi, I've updated the code to TypeScript and added typescript type definitions, it should be fixed in 1.3.1 now. https://github.com/IjzerenHein/react-tag-cloud/releases/tag/v1.3.1

Let me know whether that solves the type-definitions problem. Cheers, Hein

aienefec commented 5 years ago

Hi @IjzerenHein , simply importing the TagCloud using import TagCloud from "react-tag-cloud" shows JSX element type 'TagCloud' does not have any construct or call signatures.ts(2604).

Just to be sure, I've checked other import variants like import { TagCloud } from "react-tag-cloud" but still got the error

pkellner commented 5 years ago

I'm getting the same error. Error:(27, 18) TS2604: JSX element type 'TagCloud' does not have any construct or call signatures.

IjzerenHein commented 5 years ago

Hi, I've released a new version 1.3.2 which changes the import clause. I tested it with TypeScript running in codesandbox.io and there it no longer gives any warnings. Please let me know whether this fixes the problem: https://github.com/IjzerenHein/react-tag-cloud/releases/tag/v1.3.2