Reputation: 1
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
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
Reputation: 428
Change Your class component name to
export default Layout;
it will work
Upvotes: 0
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
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
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