1
다음 구조를 사용하여 구성 요소를 만들었습니다.반응 구성 요소에 두 개의 내보내기 선언이 있습니다.
class Chip extends React.Component {
//Some Code
}
export default Chip;
그리고 구성 요소를 실행할 때 다음 오류가 발생합니다.
Uncaught Error: Element 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. Check the render method of `App`.
at invariant (webpack-internal:///1:42)
at instantiateReactComponent (webpack-internal:///79:72)
at instantiateChild (webpack-internal:///147:42)
at eval (webpack-internal:///147:69)
at traverseAllChildrenImpl (webpack-internal:///83:75)
at traverseAllChildrenImpl (webpack-internal:///83:91)
at traverseAllChildren (webpack-internal:///83:170)
at Object.instantiateChildren (webpack-internal:///147:68)
at ReactDOMComponent._reconcilerInstantiateChildren (webpack-internal:///146:183)
at ReactDOMComponent.mountChildren (webpack-internal:///146:222)
그러나 클래스를 다음과 같이 변경하면 작동합니다.
export class Chip extends React.Component {
//Some Code
}
export default Chip;
내가 뭘 잘못하고 있니?
어떻게 가져 오는지에 대해 언급하십시오. –
'import chip from'과 같은 형식으로 가져 오는지 확인하십시오./Chip' –
언급 한대로 가져옵니다. –