import * as React from 'react';
import * as ReactDOM from 'react-dom';
import {Jumbotron} from 'ui-library';
import registerServiceWorker from './registerServiceWorker';
import './index.css';
ReactDOM.render(
<Jumbotron />,
document.getElementById('root') as HTMLElement
);
registerServiceWorker();
这是index.ts
import * as React from 'react';
class Jumbotron extends React.Component<{},{}>{
constructor(props:{},context: {}){
super(props,context)
}
render(){
return (<h1>Hello, World </h1>);
}
}
export default Jumbotron
这是另一个库中定义的topheader
这是ui-library的index.ts
export {default as Jumbotron} from './jumbotron';
export {default as TopHeader} from './topHeader';
我从反应中得到以下错误
元素类型无效:需要一个字符串(用于内置组件) 或类/函数(对于复合组件)但得到:undefined。
任何帮助都可以得到赞赏。
答案 0 :(得分:0)
将您的ui-library文件更改为:
import Jumbotron from './jumbotron';
import TopHeader from './topHeader';
export { Jumbotron }
export { TopHeader }
此外,您似乎将ui-library导入为npm包。你能验证你导入的文件路径是否正确?
import {Jumbotron} from 'ui-library';
我希望它会像:
import {Jumbotron} from './ui-library';