Fork me on GitHub
#cljsrn
<
2018-02-08
>
deg10:02:54

Until now, I've used this recipe for each JS component:

(defn adapt-class [class]
  (when class
    (r/adapt-react-class class)))

(defn get-class [module name]
  (adapt-class (oops/oget+ module name)))

(defonce native-calendar (js/require "react-native-calendars"))
(def Calendar   (get-class native-calendar "Calendar"))
But, some components are different, and require accessing the component by "default", rather than its name, e.g.:
(defonce native-calendar-strip (js/require "react-native-calendar-strip"))
(def CalendarStrip (get-class native-calendar-strip "default"))
What is this default key, which is not mentioned in the component doc? Does JavaScript somehow try it automatically? Does this pattern occur often?

fabrao11:02:23

@deg the default is the javascript export way for this lib. Look at the source and you will see it

deg12:02:01

Thanks! Guess I've got to learn more es6 stuff! I plan to put together a tiny library that handles this stuff, once I have a bit more under my belt. It looks like most of the cljsrn projects I find online are duplicating tiny variations of the same things.

pablore14:02:52

Happy to work on that library once you start it

deg14:02:00

Great! I'll announce here when I start. I hope sometime next week. (Ping me then, too, if this has scrolled off Slack's history).

deg18:02:06

@U7V9HE682 I've started. Very little so far: just a skeleton and one macro. Way too early to announce anything. But I'd love to accept PRs if you have good stuff to contribute. https://github.com/deg/radon

pablore18:02:54

Great! What are your main objectives for a first release?

deg18:02:21

I want to go through some of the existing projects on github, see what else other folks have done, and include whatever looks good. At the very least, loading components, managing styles, and console debug support. I want to do some cleanups... document what there is, and use best practices (e.g., almost everyone is improperly using aget on object properties). I want to get a little further on my toy project that uses this, and see what it needs.

deg18:02:37

What do you want to have and/or to do?

pablore19:02:39

Will this be just for react-native or react and es6 in general

deg19:02:53

For now, just react-native. But, it's one of a family of mini-libraries I'm doing and others are for re-frame, so I'm not opposed to adding more; just maybe in separate libraries.