Is it possible to spread in more than one props map? I want something similar to
($ component {:& props & extra-props})
In my case, props is a CLJS map and extra-props is a JS map generated by react-hook-form.is there a reason you can't https://clojuredocs.org/clojure.core/merge them?
($ component (merge props (js->clj extra-props)))
or simklarwant to avoid having to js->clj at run-time only for helix to take the map and clj->js again
im aware of this approach but am looking for an alternative, if it exists, since the approach in my head seems wasteful
there isn't currently a way, but helix could provide a helper function for it in the future
e.g.
($ component {& (helix/merge-props props extra-props)})you could also do something like
($ component {& (merge props (cljs-bean.core/bean extra-props))})that's basically what defnc does to props passed to you component
Hello using helix to display a MaterialReactTable component. Is there a way to refer to that in a different component and call the table functions? Basically something like let [t ($ MaterialReactTable …] and then at the click of a button (.getAllColumns t) . Sorry if this is my misunderstanding of how react components work!
So you put me on the right track but use-ref fails because it’s an invalid hook call. It may be because I’m mixing reagent and helix and the let is within a reagent element. Is there a way to achieve what I’m trying to do without recreating a whole functional component? Or can I easily convert a reagent element into a functional react element?
As long as you aren’t using create-class you should be able to make it a functional component using :f> I think. Or you can use an atom as the ref, pretty sure that’s the standard reagent way, then you don’t need hooks
Yeah I’ve seen these. It somehow works without dereferencing which tricked me in the first place. Maybe “current” is already a view for material-react-table
You nailed it, :f> works. Atom didn’t for some reason. Thank you SO much!
Edit because you made me think: atom works, my bad, but you need to do (aget myatom “current”) without dereferencing
Hmm think you should deref if you use an atom, these are the reagent docs I was referring to https://github.com/reagent-project/reagent/blob/master/doc/FAQ/UsingRefs.md But glad the hooks way works for you 😊
you probably want to store a ref and call .getAllColumns on that instead
something like
(let [table-ref (use-ref)]
($ MaterialReactTable { .... tableInstanceRef: table-ref}))
how you store the ref is up to you, maybe using a context or some global store, or just pass it downbut you can then do
(.getAllColumns table-ref)
Thanks Alex! Let me try