[英]'Header' is defined but never used no-unused-vars
我是Reactjs的新手。 我創建了一個應用程序,並嘗試在app.js中加載標頭組件。 當我嘗試加載Header組件時,顯示為在命令提示符下引發警告錯誤,如下所示:
./src/components/Header.jsx
Line 2 'Header' is defined but never used no-unused-vars
當我運行應用程序時,也會在瀏覽器中引發錯誤
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.
在App.js上檢查代碼:24
我在根目錄中添加了文件“ .eslintrc”,並在其下面添加了以下代碼
{
"parserOptions": {
"ecmaFeatures": {
"jsx": true
}
},
"rules": {
}
}
到目前為止,沒有任何效果。 誰能幫我這個忙。
請將Header.jsx
重命名為Header.js
確保將以下代碼行放在App.js之上:
import {Header} from '/src/components/Header.jsx'
確保將export
放在class Header {..}
前面
希望有幫助;-)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.