Fork me on GitHub
#fulcro
<
2021-03-16
>
stuartrexking01:03:49

Is there a simple dynamic router example where a link in a menu is “active” based on the current route?

stuartrexking01:03:13

In my menu item component, how can I tell if the item is active based on some external router?

stuartrexking01:03:36

Do I query for the state machine and compare that to the target in the store?

stuartrexking02:03:58

The approach I’m going with is to query for my router in my menu item, get the :target from :local-storage, and compare that to the ident of the component that the item routes to. If it’s a match, then it’s active, otherwise not. It feels a little icky having to look up the router in the menu item. If anyone has any better suggestions please share!

jb recluse18:03:36

https://github.com/fulcrologic/fulcro-template/blob/master/src/main/app/ui/root.cljs#L185-L191 is this equivalent to what you're trying to do? current-route is more involved than what you've described, but i think it ends up about the same in normal situations https://github.com/fulcrologic/fulcro/blob/2e38ab328ac4ef9f06778cf117fdc677ceec4aa5/src/main/com/fulcrologic/fulcro/routing/dynamic_routing.cljc#[…] definitely possible i'm misunderstanding or missing a complexity

stuartrexking03:03:50

@U017JCS7L2Y Thanks. This is much simpler.

Marcus11:03:38

Which function can I use to get the current state of the db?

Björn Ebbinghaus11:03:31

com.fulcrologic.fulcro.application/current-state

Marcus12:03:33

Thanks @U4VT24ZM3. What about the normalized database. Is there a function to get that as well?

Björn Ebbinghaus12:03:36

It is normalized.

Marcus12:03:34

ok. thanks 🙂 trying to learn this stuff

tony.kay14:03:25

consider watching the video series (there are two series now), and reading at least the first few chapters of the book.

Marcus13:03:52

@U0CKQ19AQ Yes! I have read the four first chapters in your book now + the minimalist intro by Jakub. I've also just started on the fulcro 3 series on youtube. Which is the other one?

tony.kay15:03:55

Grokking Fulcro on YouTube…it’s a lot more detailed. Not really for beginner beginners, but ok for ppl that have experience elsewhere

Marcus11:03:56

@U0CKQ19AQ thanks. I will look into that as well 🙂