reactjs - "React.CreateElement: type is invalid" after creating typings for an existing js module -
i'm trying use react-images in typescript project. there no @types/react-images
package, creating typings myself. have done before other packages no problem. process of creating declarations existing javascript modules described here.
when provide simple .d.ts
file like,
declare module 'react-images' { export default class lightbox extends react.component { } }
and import , use in project this,
import lightbox 'react-images' ... return (<lightbox images={ images } onclose={ ():any => null } { ...defaultprops } />)
i following error in browser:
warning.js:35 warning: react.createelement: type invalid -- expected string (for built-in components) or class/function (for composite components) got: undefined. forgot export component file it's defined in.
i'm wondering if may able shed light onto might doing wrong here.
typical solutions kind of problem include changing way 1 includes module include mymodule
style include { mymodule }
style. however, module writing typings declares class like,
class lightbox extends component {
and exports like,
export default lightbox;
(see relevant file)
so importing import lightbox from
style, default export. notably, when try log imported object console.log
undefined. leads me suspect there up.
currently .d.ts
file react-images looks like,
declare module 'react-images' { import * react 'react' export interface ilightboximages { src: string, srcset?: any[], caption?: string | element, thumbnail?: string, } export interface ilightboxprops { images: ilightboximages[], onclose: () => void, backdropclosesmodal?: boolean, closebuttontitle?: string, currentimage?: number, customcontrols?: any[], enablekeyboardinput?: boolean, imagecountseparator?: string, isopen?: boolean, leftarrowtitle?: string, onclickimage?: any, onclicknext?: any, onclickprev?: any, preloadnextimage?: boolean, rightarrowtitle?: string, showclosebutton?: boolean, showimagecount?: boolean, showthumbnails?: boolean, theme?: object, thumbnailoffset?: number, width?: number, } export default class lightbox extends react.component<ilightboxprops, any> { } }
as have tried build interfaces proptypes provided in package.
Comments
Post a Comment