Routing
Maqola yozilish jarayonida
Uning yaratilishini tezlashtirish uchun siz:
- 📢 Fikr-mulohaza ulashing chiptada (sharhlar/reaksiya emoji)
- 💬 Mavzu boyicha to'plamlarni chiptaga yig'ish suhbatdan olingan material
- ⚒️ Hissa qo‘shish har qanday boshqa yo'l bilan
🍰 Stay tuned!
Situation
Urls to pages are hardcoded in the layers below pages
<Card>
<Card.Title
href={`/post/${data.id}`}
title={data.name}
/>
...
</Card>
Problem
Urls are not concentrated in the page layer, where they belong according to the scope of responsibility
If you ignore it
Then, when changing urls, you will have to keep in mind that these urls (and the logic of urls/redirects) can be in all layers except pages
And it also means that now even a simple product card takes part of the responsibility from the pages, which smears the logic of the project
Solution
Determine how to work with urls/redirects from the page level and above
Transfer to the layers below via composition/props/factories
See also
Sahifa foydali boldimi?
Sizning fikr-mulohazalaringiz hujjatlarni yaxshilashga yordam beradi