rum

Simple, decomplected, isomorphic HTML UI library for Clojure and ClojureScript | 0.12.8 https://github.com/tonsky/rum/blob/gh-pages/CHANGELOG.md#0128
2018-09-17T10:07:08.000100Z

is it possible to call an exported component from js?

2018-09-17T10:07:54.000100Z

I'm using shadow-cljs to create a npm module and trying to use it from a js app but I can't get a proper react component.

2018-09-17T10:11:48.000100Z

say you have component Button and it should be called like this in cljs (Button attrs child) for JS you have to export a function that does this

2018-09-17T10:12:34.000100Z

(defn ^:export button [attrs child]
  (Button attrs child))

2018-09-17T10:13:33.000100Z

now if Button expects attrs as Clojure’s hash map, you have to js->clj attrs that comes from JS, because most likely it’s going to be JS Object type

2018-09-17T10:13:58.000100Z

(defn ^:export button [attrs child]
  (Button (js->clj attrs) child))

mattly 2018-09-17T16:43:31.000100Z

you might also want to do

(defn ^:export button [attrs & children]
  (apply Button (js->clj attrs children))
since it seems the common idiom with JS react is to accept multiple children

2018-09-17T19:47:49.000100Z

2018-09-17T19:48:45.000100Z

then I get this warning

2018-09-17T19:48:50.000100Z

2018-09-17T19:49:12.000100Z

I can use it like <hello/>.

2018-09-17T19:49:46.000100Z

very cumbersome but if I do this const Hello = hello and <Hello/>, then it works.

2018-09-17T19:51:08.000100Z

I guess there is no easy way to use rum in js 😢

2018-09-17T19:51:37.000100Z

Thank you guys but if someone knows how to, please let me know.

2018-09-17T19:56:38.000100Z

I could do import { hello as Hello } from 'hello-lib' but still not so nice

2018-09-17T20:11:19.000100Z

oh, yes, this one works by switching the names in cljs

2018-09-17T20:11:27.000100Z