(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"})
Which gives errors such as "Warning: Invalid attribute name: table/dId
"
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?
@felix do you have many datascript-dbs ? that table/dld comes from it ?
IMO being explicit about what props you’re passing to your Typography
is better than forwarding all props
so that's what I thought
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)
as long as these are not nested
thanks @lilactown - makes sense
yes correct. that discussion is a figuring out a macro to avoid having to do the dissoc props :problem :keys that lilactown suggests
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).