0
votes

I'm trying to print Hello World on the localhost using React js. But the browser page is always blank whenever I run the code.

***App.js***

import React, {Component} from 'react';
import logo from './logo.svg';
import './App.css';
import greet from './components/Greet'

class App extends Component{
  render() {
    return (
      <div className="App">
      <Greet></Greet>
      </div>
    );
  }
}

export default App;



***Greet.js***
import React from 'react'
/* Greet(){
    return <h1>Hello, Neha</h1>
}*/
const Greet = () =><h1>Hello, Neha</h1>

export default Greet;

I have added the Greet component in src folder i.e., src folder -> components folder -> Greet.js

The error that I'm receiving on the terminal is :-

Failed to compile.

./src/App.js
  Line 10:8:  'Greet' is not defined  react/jsx-no-undef

Search for the keywords to learn more about each error. 
1
well you imported greet in App.jsx but you try to render Greet - WilomGfx
Oh! Yeah! My bad... Thank you @WilomGfx - Neha Chaudhary

1 Answers

2
votes

Change import greet from './components/Greet' to import Greet from './components/Greet'