Stateless functional Components

Stateless functional Components (Dumb Components)

Stateless functional Components always return jsx

// not working because 'greetings' with small g indicated an html element and Captial G is recognized as React component. html elements also need to have qoutation marks
import React from "react";
import ReactDom from "react-dom";

function greetings() {
  return <h1>hi world</h1>;
}

ReactDom.render(<greetings></greetings>, document.getElementById("root"));
// working code
import React from "react";
import ReactDom from "react-dom";

function Greeting() {
  return <h1>Hi Ahmad</h1>;
}

ReactDom.render(<Greeting></Greeting>, document.getElementById("root"));
Previous
Next