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!
> 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)Thanks, that’s the other alternative I considered and that now makes sense to me!
@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
wonderful!
yeah, anchors are definitely needed, since the list is somewhat long, and the inner content will make it a lot longer in some cases.
Added now. Ex.: Wco5
(Warning in COmponent from log nr. 5.)
How do you get the children
when inside a normal function component? It doesn't seem to be passed as props
Oh, I see... it is literally a clojure function. No react magic happening there. I thought it somehow became a react functional component.
@holyjak could we make them something a bit more readable, like get-ident-with-nil-props
so that the URLs are readable and make sense?
Ok!
thanks!
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
Yes. A signature could be: (defn my-component [props & children])
@holyjak let me know how you want to divide up the creation of anchors and I’ll dive in.
@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.
thanks a lot!
Could you send the invite to the repo again please? I’ll start working on that this morning.
Got it! thanks.
@holyjak Anchor text is done on: https://github.com/holyjak/tmp-fulcro-errors/blob/master/appendix-fulcro-errors-and-warnings.adoc