October 12
React tips for learners 2024
1. REACT kirish
- Nima uchun React???
- (Netflix va Instagram kabi platformalar React.js da yaratilgan.)
- Facebook kompaniyasi tominidan yaratilgan va qo'llab quvvatlanadi
- React.js- bu Javascript kutubxonasi xisoblanadi. (Faqat Reactda yaratilgan saytlar SPA SINGLE PAGE APPLICATION) deb ham yuritiladi. Sabab unda faqat yagona #root html sahifa bo'ladi.
- Oddiy web sahifa bilan React.js da yaratilgan sahifaning farqi
index.html #root -> index.html
- Node.js
- Community Material Theme
- Auto Close tag
- Auto Rename tag
- Beutify
- Code runner
- Code Snap
- Eslint
- Live Server
- Simple React Snippets
2. React.Js da Hello World Dasturi
npx create-react-app myapp (Happy Hacking๐๐๐๐๐๐๐คฃ๐)
-Reactdagi myapp papkamizda nimalar mavjud
- node-modules (bizga barcha kutubxona va texnologiyalar joylashgan hajmi ham katta)
- public - (bunda asosa Root faylimiz index.html sahifamiz joylashadi)
- src - (Butun React kodlarimz componentlarimz joylashadi.)
- .gitignore (bu gitdan ko'chirib olganimz uchun bu fayl mavjud)
- {}package-lock.json (node modulus ni qaysi versiyada ishlayotganinin belgilab beradi)
- {}package.json (Bizning websitimizning hujjati-passporti)
- Readme.md
- Ishga tushirish uchun cmd dan myapp ichiga kirib so'ngra
- import ReactDOM from 'react-dom'
// ReactDOM.render(nimani joylay, qayerga joylay)
- ReactDOM.render('Hello World',document.getElementById('root'));
JSX sintaxsis
- JSX nima???
- JSX - Javascript XML ya'ni Javascript ichida HTML hamda HTML ichida Javascript.
- JSX yordamida biz Reactda HTML kodlarimizni yozish imkoni mavjud
- JSX ni biz React.createElement() metodi yordamida ishlatishimz mumkin
*********************-------------********************
-import ReactDOM from 'react-dom'
-import React from 'react'
-REACTDOM.render(
React.createElement("h1",{},"Salom Do'stim"),
documnet.getElementById('root')
)
*****************______________********************
<div class="container">
<h1>Qalaysizlar?<h1/>
<div class="box">
<p>Ixtiyoriy matn</p>
</div>
<div/>
Variables and Expressions in React'
- Language Mode: JavaScript React
- JSX ni ishlatayotgandagi qoidalar
- JSX da o'zgaruvchilarni ishlatish
- Variables (O'zgaruvchilar)+
- Arrays
- Objects
- Attributer
- Rasmlardan foydalanish
- JSX da Inline CSS ishlatish
- React events
React table
React table using data from Objects in array
website structure in React ****Components and Small react projects
- -Yangi React App yarating
- -App.js componenta yarating
- -Header.js component yarating va <header></header> elementi ichiga <h1/> tegida Welcome To Our Website
- degan yozuv bo'lsin
- - .content classini render qiladigan Content.js nomli komponent yarating va <div> ichida <h1> title va <p>
- ma'lumot yozish uchun joy bo'lsin
- - <footer> elementini render qiladigan Footer.js nomli komponent yarating va <footer> elementi ichida <p>
- tegida Copyright yozuv va yil (yil funksional bo'lishi kerak)
- -Yangi React App yarating +
- -App.js komponent yarating +
- -Heading.js komponenta yarating +
- -App.js komponentamizni index.js render qilib #root faylimizga uzatib bersin, App.js esa Heading komponentamizni o'z ichiga olsin. +
- -Heading.js imzda <h1> elementi joylashisn hamda ushbu element ichida agrda soat 00- 12 00 gacha bo'lsa
- "GoodMorning" va rangi qizil rangda, agarda "12 00 dan 18 00" gacha bo'lsa "Good After NOON" va rangi sariq rangda , aks xolda "Good Night" va rangi yashil xolatda chiqishi kerak.