我有測試組件,我想用它在ShowTest作爲渲染一個組件到另一個
import React from "react";
export default class Test extends React.Component{
render() {
return (
<div>hi test</div>
);
}
}
我渲染測試,以ShowTest如下
import {Test} from "./test";
import React from "react";
export default class ShowTest extends React.Component{
render() {
return (
<div>
<Test />
</div>
);
}
}
然後我使用ShowTest到另一個零件。
但我收到此錯誤
Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined
無法弄清楚爲什麼發生這種情況。
沒有你在'ShowTest'組件進口'Test'? – nrgwsth
**你是如何導入'Test'的? [可能有關?](http://stackoverflow.com/questions/34130539/uncaught-error-invariant-violation-element-type-is-invalid-expected-a-string)(抱歉,首先編輯是錯誤的鏈接) – Hodrobond
嘗試從「./test」導入測試' – Hodrobond