reagent

A minimalistic ClojureScript interface to React.js http://reagent-project.github.io/
West 2021-04-20T00:26:33.157300Z

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

athomasoriginal 2021-04-20T00:49:46.158400Z

> 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:

athomasoriginal 2021-04-20T00:53:38.161500Z

> 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.

athomasoriginal 2021-04-20T00:54:04.161900Z

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

athomasoriginal 2021-04-20T00:56:37.162900Z

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

athomasoriginal 2021-04-20T00:57:20.163500Z

@c.westrom ^^ Hope it helps πŸ™‡

NoahTheDuke 2021-04-20T13:08:47.163900Z

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

1❀️
Lu 2021-04-20T14:23:05.165100Z

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

1πŸ‘
NoahTheDuke 2021-04-20T14:35:46.165700Z

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

1πŸ‘
NoahTheDuke 2021-04-20T14:36:28.166400Z

this is straying into #reitit territory tho

athomasoriginal 2021-04-20T15:06:35.166700Z

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

NoahTheDuke 2021-04-20T15:06:57.166900Z

i saw that! thank you

athomasoriginal 2021-04-20T15:07:22.167100Z

No problem! Just wanted to give them credit also and promote visibility πŸ™‚ UPDATE: haha I should just read the rest of the posts πŸ˜…

1πŸ˜†