1

Just started using react and i am following a tutorial. I have the same code as him but i am getting the following error.

./src/index.js

Attempted import error: './components/App' does not contain a default export (imported as 'App')###

Here are my index and component file.

my index.js file

import React from 'react';
import ReactDOM from 'react-dom';
import  App from './components/App';


ReactDOM.render(

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

)

my App.js

import React, {Component} from 'react';

class App extends Component {
  render(){
    return(
      <div>Ageteller Component</div> 
    )
  }   
}
2
  • 2
    how are you exporting from App? Commented Jul 10, 2019 at 20:28
  • 1
    You didn't export the class: export default class App extends Component { ... } Commented Jul 10, 2019 at 20:33

2 Answers 2

2

You need to export your App component.

Under the component put export default App

It should look like:

import React, {Component} from 'react';

class App extends Component {
  render(){
    return(
      <div>Ageteller Component</div> 
    )
  }   
}

export default App
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks a lot. The guy didnt import and his code ran, i have no idea how lol
0

export the App Component Try following

import React, {Component} from 'react'; 
    export default class App extends Component {
      render(){
        return(
          <div>Ageteller Component</div> 
        )
      }   
    }

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.