Closed margozzi closed 5 years ago
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)
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"
/>
)
}
I have rewritten this project in TS, so the upcoming 1.7 release will be compatible :)
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 containingdeclare 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 => } />