Berine
Berine

Reputation: 1

I don't know what to do with this ReactJS problem

I'm new to React and facing issues when I want to output "my hello welcome to react". I have gone through documents and youtube videos still can't identify fault.Here is the code:

import React, { Component } from 'react';
import logo, { ReactComponent } from './logo.svg';
import './App.css';
import ReactDom from "react-dom";
class Layout extends React.component {
  render(){
    return(
      <h1>hello welcome to reactjs</h1>
    );
  }
}
let app = document.getElementById("root")
ReactDom.render(<Layout/>, app)
export default App;

Here is the compile error from the compiler

Failed to compile
./src/App.js
Line 20:16:  'App' is not defined  no-undef

Upvotes: 0

Views: 81

Answers (5)

Seerat Ahmed
Seerat Ahmed

Reputation: 277

Either remove this line

export default App;

or change the line to this

export default Layout;

Basically, you are getting this error because you're trying to export App component and in the current file there isn't any component exist named App

Upvotes: 1

Anil Singha
Anil Singha

Reputation: 428

Change Your class component name to

export default Layout;

it will work

Upvotes: 0

Ankesh Ramani
Ankesh Ramani

Reputation: 21

Your code won't compile properly since App is not defined.

export default App;

You probably wanted to export Layout.

export default Layout;

Upvotes: 1

TopW3
TopW3

Reputation: 1527

You don't need to export anything. You're rendering the Layout component in the DOM directly.

Please delete this line and try.

export default App;

Upvotes: 0

kind user
kind user

Reputation: 41893

Your code won't compile properly since App is not defined.

export default App;

You probably wanted to export Layout.

export default Layout;

Upvotes: 0

Related Questions