Elshodev | Hayot & Kod
32 subscribers
123 photos
19 videos
4 files
30 links
Salom, men Elshod!
Bu kanalda sizga Front-end dasturlash bo‘yicha tajribam, hayotimdagi o‘zgarishlar, motivatsiya va shaxsiy rivojlanish haqida yozib boraman.
Kod yozamiz, hayot haqida fikrlashamiz, oldinga birga yuramiz!
Download Telegram
React’da createPortal nima?
Oddiy qilib aytganda, createPortal componentni yozilgan joyida emas, DOM’ning boshqa joyida chiqarish uchun ishlatiladi.
Masalan modal button ichida turadi:
<MoreFilters />

Lekin modal ochilganda u button turgan joyning ichida emas, to‘g‘ridan-to‘g‘ri document.body ichida chiqadi.
Nega kerak?
Agar modal parent div ichida qolsa:
overflow hidden modalni kesib qo‘yishi mumkin
z-index ishlamay qolishi mumkin
fixed modal noto‘g‘ri joyda chiqishi mumkin

createPortal esa modalni body ichiga chiqaradi va modal butun ekran ustida to‘g‘ri ko‘rinadi.
Oddiy misol:
import { createPortal } from "react-dom";

function Modal() {
return createPortal(
<div className="fixed inset-0 bg-black/40">
<div className="bg-white">
Modal content
</div>
</div>,
document.body
);
}

Ya’ni component React’da qayerda chaqirilgan bo‘lsa ham, DOM’da body ichiga chiqadi.
🔥1
Sunʼiy intellekt kuchini qaranglar 👀
🤩2
This media is not supported in your browser
VIEW IN TELEGRAM
👏1
This media is not supported in your browser
VIEW IN TELEGRAM
🔥1
This media is not supported in your browser
VIEW IN TELEGRAM
⚡2😱1
This media is not supported in your browser
VIEW IN TELEGRAM
🆒1
This media is not supported in your browser
VIEW IN TELEGRAM
🆒2
Bugun AI’ni biroz boshqacha usulda sinab ko‘rmoqchiman 👀
Hozirgacha AI modellardan asosan internet orqali foydalangan bo‘lsam, endi AI modelni o‘z kompyuterimda local ishlatib ko‘rmoqchiman.
Buning uchun Ollama orqali model o‘rnatib, internetga bog‘liq bo‘lmagan holda qanday ishlashini test qilaman.
Qiziq bo‘lgan joyi — model to‘g‘ridan-to‘g‘ri kompyuterning o‘zida ishlaydi. Ya’ni so‘rovlar tashqi serverga ketmaydi va ishlash tezligi ham kompyuterning kuchiga bog‘liq bo‘ladi.
Hozircha tajriba 😄
Agar yaxshi natija bersa, keyin uni coding uchun ham ishlatib ko‘raman.
Natijalarini ham kanalda ulashaman 👨‍💻
2🔥1
Bizga dam yoʻq ishdamiz. Dasturlashda erkin grafik boʻladi deb oʻylar edim)
🔥2🕊1😭1
This media is not supported in your browser
VIEW IN TELEGRAM
🕊1
This media is not supported in your browser
VIEW IN TELEGRAM
🕊1
This media is not supported in your browser
VIEW IN TELEGRAM
🕊2
This media is not supported in your browser
VIEW IN TELEGRAM
🤗4
Menga qara, mabodo qachondir sun'iy intellektlar inqilobi ro'y berib, robotlar odamlar ustidan hukmronlik qilishni boshlasa, sen meni himoya qilib, yonimni olasanmi? "Bu yaxshi odam, tegmanglar", deyishingdan umid qilsam bo'ladimi? :)
The less you want, the richer you are. The more you need in order to be happy, the more miserable you'll be.
💯3
Men haqimda bilganlaring bo'yicha xonani to'ldir

ChatGPT:
👍5