diff --git a/Inception/App.js b/Inception/App.js index ffc4519..2647cce 100644 --- a/Inception/App.js +++ b/Inception/App.js @@ -1,61 +1,67 @@ import React from "react"; import ReactDOM from "react-dom/client"; -// const heading = React.createElement( -// "h1", -// {id:"heading",'data-cy':"h1_heading" }, -// "Hello Jayesh from React"); +//const heading = React.createElement("h1", {id:"heading"}, "Namaste React 🧑‍💻"); +//console.log(heading); -// console.log(heading); // heading : returns object -// const root = ReactDOM.createRoot(document.getElementById("root")); -// root.render(heading); // render the heading in the root element +// JSX - HTML like syntex for React, JSX ===> React.createElement() ==> React elements - JS objects --> DOM nodes --> Browser +// JSX code is transpied before it is rendered in the browser & JS engine. +// react element -// nested element +// react Comoonent /* -
- < div id = "child"> -

Hello Jayesh from React

-
- - - ReactElement(object) -> ReactElement(object) -> ReactElement(object) +class based component: old way write code +fucntional components: new way to write code +alwyas it starts with capital letter +const fn = () => true; +below both code are same - this is way to return +const HeadingComponent = () => { + return

Namaste React Using JSX🧑‍💻

; +} +const HeadingComponent = () => ( +

Namaste React Using JSX🧑‍💻

+); */ -// hard coded -// JSX using -const parent = React.createElement( - "div", {id:"parent"}, - [ React.createElement( - "div", {id:"child"}, - [ React.createElement( - "h1", {}, "This is Jayesh ") , - React.createElement( - "h2", {}, "Working on React 🧑‍💻🚀 "), - ]), - React.createElement( - "div", {id:"child2"}, - [ React.createElement( - "h1", {}, "There is a child2") , - React.createElement( - "h2", {}, "Child element has h2 tag"), - ])] +const spanElement = ( + This is span element + + ); + + +const jsxHeading = ( +

+{spanElement} +Namaste React Using JSX🧑‍💻 +

+); + +const TitleComponent = () => ( +
+

Title is React 👌

+
); +const number = 10000; +// component composition - combine multiple components +// using {} we can write JS code inside JSX -// JSX -// const parent = ( -//
-//
-//

Hello Jayesh from React

+const HeadingComponent = () => ( +
+ + {TitleComponent()} +

{number}

+ {jsxHeading} +

Namaste React Using JSX ❀

+
+); -//
-//
-// ); -console.log(parent); const root = ReactDOM.createRoot(document.getElementById("root")); -root.render(parent); // render the parent in the root element - +// way to render react element +// root.render(jsxHeading); +// way to render react component +root.render(); diff --git a/Inception/index.css b/Inception/index.css index bd4ad4c..83dd11c 100644 --- a/Inception/index.css +++ b/Inception/index.css @@ -6,4 +6,20 @@ margin-top: 50px; margin-bottom: 50px; +} +#heading { + color: blue; + font-size: 50px; + font-family: 'Times New Roman', Times, serif; + text-align: center; + margin-top: 50px; + margin-bottom: 50px; +} +.heading { + color: blue; + font-size: 50px; + font-family: 'Times New Roman', Times, serif; + text-align: center; + margin-top: 50px; + margin-bottom: 50px; } \ No newline at end of file diff --git a/Inception/index.html b/Inception/index.html index 0565e4a..1b458c3 100644 --- a/Inception/index.html +++ b/Inception/index.html @@ -9,8 +9,8 @@

Top of the root

-
-

Hello Jayesh from React

+
+

Not render

Bottom of the root