This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-05-09
Channels
- # babashka (176)
- # beginners (26)
- # cider (1)
- # cljsrn (3)
- # clojure (60)
- # clojure-australia (3)
- # clojure-europe (8)
- # clojure-uk (3)
- # clojurescript (1)
- # code-reviews (4)
- # community-development (3)
- # cursive (6)
- # depstar (1)
- # emacs (11)
- # figwheel (3)
- # helix (13)
- # integrant (2)
- # jackdaw (1)
- # kaocha (1)
- # leiningen (3)
- # luminus (2)
- # malli (4)
- # music (1)
- # nrepl (2)
- # off-topic (1)
- # practicalli (3)
- # reitit (3)
- # shadow-cljs (16)
- # slack-help (14)
- # sql (13)
- # vim (12)
(Is there?) What's the recommended way to avoid passing props down to "native" components. Eg
(defnc
typography-attr
[{:keys [datascript-db eid attr] :as props}]
(let [[text _ db-sync _] (change-watch datascript-db eid attr)]
($ Typography
{style (when db-sync #js{:animationName "change-notifier"})
& props}
text)))
($ typography-attr {:variant "h6"})
I found this discussion https://clojureverse.org/t/destructure-map-keys-and-also-rest-of-the-map/3988/13 - but I was wondering if I'm missing something easier that helix already recommends? even a convention such as putting all the data behind a single keyword eg :app/data or something?
this looks like something that interests me but being a cljs beginner, don't quite understand everything. So I apologize if I misunderstand, but isn't this about selecting the appropriate keys from the state (be it props or context) for the appropriate component?
yes correct. that discussion is a figuring out a macro to avoid having to do the dissoc props :problem :keys that lilactown suggests
i have not yet come up with a better idea than statically storing queries on the components themselves
@felix do you have many datascript-dbs ? that table/dld comes from it ?
just one. each "view" has a datascript instance which manages state. the table/dId is a refence to the datomic server side eid. the problem here is that React complains about any prop that has a slash in the name, so I have to remember to dissoc all props that I have passed down the component structure before rending the native components (at least in the cases where they need spread props, eg the typography example I had above).
IMO being explicit about what props you’re passing to your Typography
is better than forwarding all props
But in some cases you can also dissoc the few props you know are causing issues:
($ Typography
{:style ,,,
& (dissoc props :datascript-db :eid :attr)}
text)
thanks @lilactown - makes sense