Fork me on GitHub
#fulcro
<
2021-03-11
>
lokirrationalis13:03:26

Hello everyone! I started using Fulcro 2 days ago and I still have a hard time wrapping my head around it, so I thought I might ask a few supposedly rather simple, but very fundamental, questions here. I might be overcomplicating things, so I hope that one of you might help me out here. I came from reagent & re-frame — I’m currently building an Electron desktop app, which will later have an online backend as well though, that’s why I’m trying out Fulcro right now, still in the very early days of the application’s development. I’ve read the book in parts and also watched some of the videos on YouTube but one thing I simply do not get in my particular app right now is: Does every component get a query and a state? And do I normalize everything in the database then? I’m wondering because I have components like: icons, navigation elements in a sidebar — and yesterday I started giving my icons state like “:icon/color”, “:icon/type” etc. and at one point it simply didn’t make sense to me anymore because these icons are only used in the sidebar (and a topbar). And I don’t really see why I should be ID’ing them anyway, because then I guess I would have to start counting them or something similar that just makes no sense to me. I guess what I’m also missing thus far (at least I personally haven’t found such a ressource) is some rather mature open source app using Fulcro where I could peak into the source code from time to time and see how other people were doing things. Because when I look at the example given in the Fulcro book, those components totally make sense to me, because they are accessing some actual state, some data that might vary (like persons and people lists, stuff like that), which I don’t have with like an icon component. I’ve also looked at the template and there’s a “PlaceholderImage” which is a component without a state and a query (https://github.com/fulcrologic/fulcro-native-template/blob/master/src/main/app/ui/components.cljs). I guess I would model e.g. my icon component more or less like that. Would that be considered to be the wrong way? Sorry for these questions that must seem dumb to someone working everyday with Fulcro, but I guess I’m not the first person having issues when starting out and I have this vague feeling at this point that it’s worth it for Fulcro, so I guess I just need a little bit of help right now. 🙂 Thanks!

Björn Ebbinghaus14:03:32

> Does every component get a query and a state? No. Just write components as functions when they have no mutable state.

(defn icon [{:keys [color type]}]
  (dom/svg ...whatever..))

(icon {:color "green"})
Sometimes the defsc macro is used without a query as an optimization. (https://book.fulcrologic.com/#defscForOptimization)

lokirrationalis14:03:50

Thanks, that’s the other alternative I considered and that now makes sense to me!

Casey16:03:59

How do you get the children when inside a normal function component? It doesn't seem to be passed as props

Casey16:03:56

Oh, I see... it is literally a clojure function. No react magic happening there. I thought it somehow became a react functional component.

Björn Ebbinghaus16:03:37

Yes. A signature could be: (defn my-component [props & children])

Jakub Holý (HolyJak)15:03:05

@tony.kay regarding the errors appendix, something likes this https://gist.github.com/holyjak/0776669d6c84681fde4a09bf8b6d01a6 ? Plus I need to generate anchors for each log entry so that we can refer to them, plus of course try to write some explanations // cc @alex-eberts

tony.kay15:03:04

yeah, anchors are definitely needed, since the list is somewhat long, and the inner content will make it a lot longer in some cases.

Jakub Holý (HolyJak)16:03:39

Added now. Ex.: Wco5 (Warning in COmponent from log nr. 5.)

tony.kay16:03:34

@U0522TWDA could we make them something a bit more readable, like get-ident-with-nil-props

tony.kay16:03:42

so that the URLs are readable and make sense?

tony.kay16:03:59

Feel free to send a PR on dev guide with an include for your appdx (or just put it inline), and I’ll publish it so you can verify links

alex-eberts17:03:41

@U0522TWDA let me know how you want to divide up the creation of anchors and I’ll dive in.

Jakub Holý (HolyJak)17:03:31

@alex-eberts I got an invitation to collaborate on https://github.com/holyjak/tmp-fulcro-errors/blob/master/ Feel free to just edit it on master (you can do that directly in the browser). Just get going if you want. Also, please insert what you have written at the appropriate places. Note: the anchors should be put inside the [[]] at the beginning of each line.

alex-eberts17:03:51

Could you send the invite to the repo again please? I’ll start working on that this morning.

alex-eberts17:03:28

Got it! thanks.