Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
125
rated 0 times [  127] [ 2]  / answers: 1 / hits: 11070  / 2 Years ago, sat, january 15, 2022, 12:00:00

heyyy. i wanted to try out react with this tutorial.


at the moment I have only made the data structure. unfortunately i always get an error when compiling.




Error


Compile failed.

Attempted import error: './App' does not contain default export (imported as 'App').
Assets by state 1.6 MiB [cached] 2 assets
Assets by path . 930 bytes
asset index.html 658 bytes [emitted]
asset-manifest.json 272 bytes [emitted]
cached modules 1.39 MiB (javascript) 1 bytes (asset) 28.1 KiB (runtime) [cached] 144 modules
./src/index.js 1.34 KiB [built]

ERROR in ./src/index.js 8:38-41
export 'default' (imported as 'App') was not found in './App' (possible exports: App)

webpack 5.66.0 compiles with 1 error in 63 ms



App.js


import React from 'react'

import { Footer, Blog, Possibility, Features, WhatWELOVEU, Header } from './containers';
import { CTA, Brand, Navbar } from './components';

export const App = () => {
return (
<div className='App'>
<div className='gradient_bg'>
<Navbar />
<Header />
</div>
<Brand />
<WhatWELOVEU />
<Features />
<Possibility />
<CTA />
<Blog />
<Footer />


</div>
)
}



index.js


import React from 'react';
import ReactDOM from 'react-dom';

import App from './App';

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



these two files are in the "src" folder. in the "src" folder there are also the components and containers. everything is described in the tutorial and the data structure is the same.
enter image description here




In the folder components and container are .jsx and css files. all css FIles nid empty, in the jsx files you can find the same code always adapted to the name of the file.


p.ex.
Article.jsx


import React from 'react'
import './article.css';

const Article = () => {
return (
<div>
Article
</div>
)
}

export default Article

enter image description here




In containers and components are also index files.


components/index.js


export { default as Article } from './article/Article';
export { default as Brand } from './brand/Brand';
export { default as CTA } from './cta/CTA';
export { default as Feature } from './feature/Feature';
export { default as Navbar } from './navbar/Navbar';

containers/index.js


export { default as Blog } from './blog/Blog';
export { default as Features } from './features/Features';
export { default as Footer } from './footer/Footer';
export { default as Header } from './header/Header';
export { default as Possibility } from './possibility/Possibility';
export { default as WhatWELOVEU } from './whatWELOVEU/whatWELOVEU';

More From » reactjs

 Answers
2

try this in you index.js


import { App } from './App'

or you could change in your App.js to this


import React from 'react'

import { Footer, Blog, Possibility, Features, WhatWELOVEU, Header
} from './containers';
import { CTA, Brand, Navbar } from './components';

export default const App = () => {
return (
<div className='App'>
<div className='gradient_bg'>
<Navbar />
<Header />
</div>
<Brand />
<WhatWELOVEU />
<Features />
<Possibility />
<CTA />
<Blog />
<Footer />
</div>
)
}

Two options. Choose one.
Hopefully can help you.


[#484] Monday, January 10, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
lailab

Total Points: 706
Total Questions: 102
Total Answers: 95

Location: Falkland Islands
Member since Mon, Jul 13, 2020
4 Years ago
lailab questions
Fri, Feb 21, 20, 00:00, 4 Years ago
Tue, Feb 4, 20, 00:00, 4 Years ago
Sun, Apr 14, 19, 00:00, 5 Years ago
;