Some Call Me Tim
Create route which opens a modal
cool. So just so I'm clear on what you're wanting: if someone goes to mydomain.com/login, it shows a regular login page, but if someone goes to mydomain.com/whatever, and clicks a login button, you want the browser to display mydomain.com/login, but -not- navigate to the actual login page, but instead display the login overlay?
15 replies
Create route which opens a modal
My 2c is that a route is a route. If I'm reading your request right, you want to shoehorn functionality that should be a simple boolean value in a global context into the router logic.
i.e. example.com/login should go to a login page, having that in the url bar when on example.com/pricing would navigate to example.com/login, not keep the user on the pricing page with a login popup.
I have this exact functionality with a contact form and no messing around with routes. Store a 'loginFormOpen' boolean in a globally available context, and have the login form hidden via
<Show>
somewhere pretty high up the tree. Now, from anywhere in your site, you can flick that boolean to 'true' and your login screen can magicaly overlay any content that is currently on screen. Add Solid Transition Group for some sparkle.15 replies
Hydration mismatch
yup, could do a context too, but personally for something like tabs/popups or whatever, it'd be just more mental overhead with the 'oh did this register', 'did this unload' etc. I'd rather just have it verbose like above where the chlid is tied to the parent. The joys of flexibility 🙂
27 replies
Hydration mismatch
Some of those rub me the wrong way, lots of footguns. For one, there's no way to enforce the type of children. Like the tabs for example, I'd have the
<Tab>
component render its own content. Maybe it's just user preference though.
One thing I do like is a setup i found ages ago... here's a snippet from a popup menu I made:
All it takes is a PopupMenu.MenuItem = PopupMenuItem;
at the bottom of the PopupMenu.tsx
file.27 replies
Router primitives can be only used in side a Route.
Sooo, the actual issue was that on the redirect from Component B back to Component A, the routeData function is called using an internal
_server
url, which didn't have access to use useLocation().
I also found getRequestEvent();
, so I was able to find out what caused the issue with useLocation(), but also able to get rid of useLocation() 🙂35 replies
Router primitives can be only used in side a Route.
next question is how can I only run middleware for 1 route block? i.e. I've got 100 routes, but only need it to run on this block of 3 which are nested in a
ViewersRoute
component .
35 replies