I'm trying to import the CarList component which is in /src/components/CarList.js into App.js

I get this error

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

App.js

import React, { Component } from "react"; import logo from "./logo.svg"; import "./App.css"; import CarList from "./components/CarList"; class App extends Component { render() { return ( <div className="App"> <header className="App-header"> <img src={logo} className="App-logo" alt="logo" /> <h1 className="App-title">Welcome to React</h1> </header> <CarList /> </div> ); } } export default App; 

CarList.js

 import React, { Component } from 'react'; class CarList extends Component { render() { return ( <div> This will be the car list </div> ); } } 

I tried almost everything from the first page of Google, which does not help. What can be wrong?

  • export default CarList is at the end of the CarList class? well, or export default class CarList extends Component {} - Denis Klimenko
  • There is. It seems the problem was solved by installing reactstrap. Thank you - Xmahop Abuse

1 answer 1

You need to export CarList at the end of the CarList.js file CarList.js

 import React, { Component } from 'react'; class CarList extends Component { render() { return ( <div> This will be the car list </div> ); } } export default CarList;