How should I organize my app where it has different behavior in responsive layout?

(Screenshot) for example Modal on Desktop vs New Page on Mobile.
5 Replies
Leonidas
Leonidas3y ago
Could you elaborate on your question? I feel like you already answered it urself
Mir
MirOP3y ago
How would you organize this two separate behavior structurally in code?
Leonidas
Leonidas3y ago
The content of the page/modal stays the same. Move it to an own component Afterwards define a page and a modal with that component Use a media query to detect the device width, for mobile open a new page (or a drawer would be suiting too) and for desktop open the modal If possible wrap this „two-way“ behaviour in a own wrapper component and add a comment to explain what happens in a short sentence.
Mir
MirOP3y ago
I decided to go with this way. Does this look good?
# Comp:
- MobileComp
- DesktopComp

# SharedComps
# Comp:
- MobileComp
- DesktopComp

# SharedComps
Leonidas
Leonidas3y ago
/SettingsInput index.tsx /components Modal.tsx Drawer.tsx Content.tsx Is an alternative suggestion, but do it it the way that suits your project And use a more explicit name than SettingsInput, this is just a generic example That approach is called one-file-per-component, served me well
Want results from more Discord servers?
Add your server