helix

rgm 2022-01-11T01:31:54.005Z

More and more there seems to be hooks-based React stuff I'd like to use in my Reagent projects. My first thought is that I'd like to put it all behind a component interface down in a private lib and use Helix to provide the interface ... reagent then is none the wiser. Is there good guidance anywhere on the current way to do this? I guess some of this question is around using the :bundle target and somehow not pulling in React twice, as well as how exactly that vanilla cljs compiler :bundle target interacts with libraries.

rgm 2022-01-11T01:32:17.005600Z

it's possible these statements aren't even wrong; I'm just forming up the problem in my head

rgm 2022-01-11T02:03:42.010Z

hm, think I've figured it out with figwheel's autobundle. But it seems like the consuming project has to know what NPMs the cljs lib needs so it can be provided somehow (eg react, react-dom). In my case, I'm trying to use downshift-js and react-select as internal implementation details. Is there an in-band way to publish this so the parent doesn't have to specify it, or is it a thing you just have to document?

rgm 2022-01-11T02:05:30.011700Z

(not the end of the world if so; there's still some value in providing a handy cljs wrapper to hide a lot of the tedious cli->js/bean goop).

lilactown 2022-01-11T04:10:30.012100Z

you can easily use helix components in your app.

lilactown 2022-01-11T04:10:53.012700Z

in fact, you can use helix $ and react components anywhere in your reagent components

lilactown 2022-01-11T04:11:55.014Z

(defn my-reagent-component
  []
  [:div
   [:div ($ helix-component {:foo "bar"}
            (r/as-element [another-reagent-component [:div "child"]]))]])

lilactown 2022-01-11T04:13:01.014800Z

regarding :bundle and the deps/lib stuff... not really sure

lilactown 2022-01-11T04:14:14.015900Z

> Is there an in-band way to publish this so the parent doesn't have to specify it, or is it a thing you just have to document? publishing a CLJS lib that depends on an npm lib can be done using a https://clojurescript.org/reference/packaging-foreign-deps

lilactown 2022-01-11T04:15:28.016700Z

however, I removed the one from helix because the compiler was warning people when they used a different version of React than I specified. I simply document that you must use a version of react with hooks in it

rgm 2022-01-11T06:06:21.020Z

Thanks. I was shocked that I actually got it working in the consuming app. It's gotten so much easier than it was back when I got started in cljs. I'll take a look at deps.cljs … somehow I missed that. Not planning to put in react but some of the more exotic npm stuff that it's hard to imagine conflicting.

rgm 2022-01-11T06:10:54.021200Z

I've kind of lost track of whether it's socially encouraged to rely on cljsjs or is the new bundle stuff preferred where possible.

rgm 2022-01-11T06:12:34.021900Z

Oh wait deps.cljs is the mechanism for cljsjs. Never mind me.