0
我是新来的reactjs。我创建了一个应用程序,并尝试在app.js中加载头部组件。当我尝试加载头组件显示它抛出警告在命令提示符误差'Header'已定义,但从未使用no-unused-vars
./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'? – evolutionxbox
你想尝试像“从./components/Header'”导入标题?如果是,我已经只使用标题。 – krrr25
是的,这就是问题所在:您导入它,但从未使用它。将它添加到渲染函数的返回值中。 –