Fork me on GitHub
#reagent
<
2021-04-20
>
West00:04:33

Hey guys, I'm looking for a super simple way to do routing in Reagent? I don't know much about how routes work. I know that usually in HTML I would just have my hyperlinks point to a relative link in my directory structure. In reagent, since it's single page, it won't do that. I looked at a library called reitit, but it seems a bit too complicated. Also, what are some complications when it comes to SPA routing? I know history is something I might want to play with, but otherwise I can't think of anything else. How can I change which view is active when I click on a hyperlink? Also, would this be better asked in beginners? Here's me repo: https://gitlab.com/wildwestrom/mysite

athomasoriginal00:04:46

> I looked at a library called reitit, but it seems a bit too complicated https://gist.github.com/athomasoriginal/eadc022482c3432943c400cc8eeb1788 I setup to show someone else how to do this:

athomasoriginal00:04:38

> what are some complications when it comes to SPA routing? Watch out for scroll position and redirect. You may not run into them, but just in case. Each are straightforward to resolve, the tricky part can be identifying them.

athomasoriginal00:04:04

> How can I change which view is active when I click on a hyperlink? The gist should cover that

athomasoriginal00:04:37

If you do go with reitit, which I recommend, they have several front end specific examples for routing.

athomasoriginal00:04:20

@c.westrom ^^ Hope it helps 🙇

NoahTheDuke13:04:47

that gist is great! wish they'd put something like that in the docs

❤️ 3
athomasoriginal15:04:35

They do have examples like this, but the one I provided is diving concerns in a different way https://github.com/metosin/reitit/tree/master/examples/frontend

NoahTheDuke15:04:57

i saw that! thank you

athomasoriginal15:04:22

No problem! Just wanted to give them credit also and promote visibility 🙂 UPDATE: haha I should just read the rest of the posts 😅

😆 3
Lu14:04:05

Something really close to that gist is in the reitit-fronted docs ... I don’t think it makes sense for reagent to have it on their docs: https://github.com/metosin/reitit/blob/master/examples/frontend/src/frontend/core.cljs

👍 3
NoahTheDuke14:04:46

my apologies, I meant the reitit docs. the section on "frontend" isn't super clear: https://cljdoc.org/d/metosin/reitit/0.5.12/doc/frontend

👍 3
NoahTheDuke14:04:28

this is straying into #reitit territory tho