helix

https://github.com/Lokeh/helix
xlfe 2021-05-09T12:33:04.078300Z

(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"})

xlfe 2021-05-09T12:35:26.078800Z

Which gives errors such as "Warning: Invalid attribute name: table/dId"

xlfe 2021-05-09T12:36:26.079900Z

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?

Aron 2021-05-09T12:53:48.081600Z

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?

2021-05-09T13:27:49.082800Z

@felix do you have many datascript-dbs ? that table/dld comes from it ?

lilactown 2021-05-09T15:07:47.083700Z

IMO being explicit about what props you’re passing to your Typography is better than forwarding all props

Aron 2021-05-09T15:08:06.084200Z

so that's what I thought

lilactown 2021-05-09T15:10:14.086200Z

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)

Aron 2021-05-09T15:10:30.086500Z

as long as these are not nested

xlfe 2021-05-09T23:53:09.087100Z

thanks @lilactown - makes sense

xlfe 2021-05-09T23:54:21.087500Z

yes correct. that discussion is a figuring out a macro to avoid having to do the dissoc props :problem :keys that lilactown suggests

xlfe 2021-05-09T23:56:06.087700Z

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