Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Will not work for me at all ( does this work with typescript? ) #40

Closed
margozzi opened this issue Dec 15, 2018 · 3 comments
Closed

Will not work for me at all ( does this work with typescript? ) #40

margozzi opened this issue Dec 15, 2018 · 3 comments

Comments

@margozzi
Copy link

In VS Code if I hover over the import statement I get this test in a popup:

Could not find a declaration file for module 'react-iframe'. 'c:/cloudguest/src/client-admin/react-material.eval/node_modules/react-iframe/index.min.js' implicitly has an 'any' type.
Try npm install @types/react-iframe if it exists or add a new declaration (.d.ts) file containing declare module 'react-iframe';ts(7016)

When I run I get an error:

Check your code at App.js:43.
in Route (at App.js:43)
in Switch (at App.js:40)
in div (at App.js:34)
in App (at src/index.js:9)
in Router (created by BrowserRouter)
in BrowserRouter (at src/index.js:8)
Warning: React.createElement: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.
index.js:1452

Here is how I am trying to use it:

import { Iframe } from 'react-iframe';

<Route path="/api-docs-swagger" render={props => <Iframe url='/api-docs-swagger' />} />

@Debml
Copy link

Debml commented Jan 9, 2019

Did you try importing the component as the default, as the second warning says?

import Iframe from 'react-iframe'; (notice the lack of {} wrapping Iframe)

The warning is just VS code complaining that there is no file to map props to types, so you get no intellisense/type checking on the props, but shouldn't break your build (if you get the type wrong, it might break at run time though)

@framebassman
Copy link

framebassman commented Feb 28, 2019

I've got the following error with my code:

Type error: Could not find a declaration file for module 'react-iframe'. 'Client/node_modules/react-iframe/index.min.js' implicitly has an 'any' type.
  Try `npm install @types/react-iframe` if it exists or add a new declaration (.d.ts) file containing `declare module 'react-iframe';`  TS7016

PayButton.tsx:

import React from 'react';
import Iframe from 'react-iframe';

export const PayButton = () => {
  return (
    <Iframe
      src="blablabla"
    />
  )
}

@robbestad
Copy link
Owner

I have rewritten this project in TS, so the upcoming 1.7 release will be compatible :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants