0

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. 
2
  • well you imported greet in App.jsx but you try to render Greet Commented Oct 6, 2019 at 18:57
  • Oh! Yeah! My bad... Thank you @WilomGfx Commented Oct 6, 2019 at 18:59

1 Answer 1

1

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

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

1 Comment

Oh!! Yeah... Thank you so much.

Your Answer

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