fulcro

Book: http://book.fulcrologic.com, Community Resources: https://fulcro-community.github.io/, RAD book at http://book.fulcrologic.com/RAD.html
lokirrationalis 2021-03-11T13:12:26.261400Z

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 Ebbinghaus 2021-03-11T14:33:32.261600Z

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

lokirrationalis 2021-03-11T14:56:50.261800Z

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

Jakub Holý 2021-03-11T15:40:05.263300Z

@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

Jakub Holý 2021-03-12T14:50:51.283600Z

wonderful!

tony.kay 2021-03-11T15:43:04.264300Z

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ý 2021-03-11T16:16:39.264500Z

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

Casey 2021-03-11T16:37:59.264700Z

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

Casey 2021-03-11T16:39:56.264900Z

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

tony.kay 2021-03-11T16:41:34.265200Z

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

tony.kay 2021-03-11T16:41:42.265400Z

so that the URLs are readable and make sense?

Jakub Holý 2021-03-11T16:42:24.265600Z

Ok!

tony.kay 2021-03-11T16:45:22.265800Z

thanks!

tony.kay 2021-03-11T16:45:59.266Z

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

Björn Ebbinghaus 2021-03-11T16:55:37.266200Z

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

2021-03-11T17:25:41.266400Z

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

Jakub Holý 2021-03-11T17:43:31.266700Z

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

Jakub Holý 2021-03-11T17:43:35.266900Z

thanks a lot!

2021-03-11T17:47:51.267100Z

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

2021-03-11T17:56:28.267300Z

Got it! thanks.