【问题标题】:Index.js is not importing App.js even when when export is used即使使用导出,Index.js 也不会导入 App.js
【发布时间】:2021-07-18 19:26:16
【问题描述】:

即使当我使用“导出默认应用程序”时仍然有一个错误说'./App不包含默认导出(导入为'App')。在 Index.js 文件中。当我更改文件名时,错误就解决了。

这是 App.jsx 文件中的代码

import React, { useState } from 'react';
import data from './data';
import Card from './Card'
import Heading from './Heading';
const App = () => {
const state = useState();
return (
<>
  <Heading />
  <div className="cards">
    {data.map((value, index) => {

      <Card
        cardimg={value.simg}
        cardname={value.sname}
        cardtitle={value.stitle}
        cardlink={value.links}
      />
    })
     }
   </div>
 </>
);
}
export default App;

这是 index.js 文件中的代码:

import React from 'react';
import ReactDom from 'react-dom';
import './index.css';
import App from './App';

ReactDom.render(
<App/>
,document.getElementById('root')
);

【问题讨论】:

    标签: javascript reactjs export web-development-server


    【解决方案1】:

    你的 const 是 Abhay 这应该是你的出口而不是 App

    【讨论】:

      猜你喜欢
      • 2022-08-06
      • 2017-12-23
      • 2019-11-08
      • 1970-01-01
      • 2021-12-29
      • 1970-01-01
      • 1970-01-01
      • 2022-01-13
      • 1970-01-01
      相关资源
      最近更新 更多