Fork me on GitHub
#rum
<
2018-03-22
>
grounded_sage08:03:12

Is there a standard way to utilize React components in Rum?

rauh08:03:14

@grounded_sage There is not, you can do it manually like (js/React.createElement js/Foo.bar.The.Component props child0 child1). Reagent provides a special syntax for this: [:> js/The.React.Component props child0 child1], but Sablono (used by Rum) does not provide it

rauh08:03:41

Plug: With hicada you can do the same [:> ...] syntax

grounded_sage08:03:54

Oh! I will check that out.

grounded_sage08:03:23

The problem I have is I am actually very interested in doing React Native for Web. So I'm actually not needing Sablono theoretically.

rauh08:03:02

Checkout hicada in this case, there is a few ideas to make RN easier in that case with a special config flag

rauh08:03:07

Eg. define all your components in a single namespace and then just write [:Text {:foo "bar"} child0] and then specify :default-ns in the hicada config

grounded_sage08:03:06

Have you much experience with RN code in cljs? @rauh

rauh08:03:23

Nope, I've just toyed with it a few months ago

grounded_sage08:03:56

I'm very new to the idea. However looking at the RN4W project I'm convinced it's the way forward so giving it a go.

rauh08:03:44

I tried Flutter the other day. Very impressed. Super quick live reloads. Like 300ms... So very much a figwheel like experience. IDE support is also fantastic.

grounded_sage08:03:19

Think it has a chance of getting developer mindshare?

grounded_sage08:03:09

It looks like a fantastic project. Just react is so far ahead in this space I'm curious where people think it fits in.

rauh08:03:24

I'd say it has more traction than ReactNative. Tons of great work happening.

rauh08:03:53

Personally I would use Flutter instead of RN for a new project.

grounded_sage08:03:32

Interesting. Even if you were using Cljs?

rauh08:03:05

I mean i use CLJS a lot and I love it. But RN was just a pain to setup and the errors are super tough to debug. With Flutter it was just super easy. And by running a repl() function on ever reload I had very much an interactive dev experience. To get a nice UI it was just super easy and fast. I also really like tooling with Android-Studio. It's just so easy to get something on the screen quickly

rauh08:03:14

It's super quick to get started in Flutter. If you already have the SDK and Android studio it's <10min to have a starting screen.

grounded_sage09:03:43

Problems I see is not having the reach React has. Targets for desktop, vr. Plus accessibility is a WIP as well. It still needs some work but perhaps it's the better option when people have already fleshed out a prototype and want the perf? Not sure guess we will see.

grounded_sage09:03:48

Sorry I'm still a noob with Cljs/Clj. What do you mean by this Rum, simple overwrite the sablono.compiler/compile-html macro. ?

rauh09:03:09

In your src directory you create a file: src/sablono/compiler.clj and write a defn compile-html that takes the hiccup and calls into hicada and returns the CLJS/JS code

rauh09:03:31

It will be picked up instead of the sablono/compiler.clj file in the sablono jar

rauh09:03:27

@grounded_sage In that case you will have to wrap your defc bodies in a call to that html macro.

rauh09:03:04

When using the hack to overwrite sablono you can just write (defc [..] [:div ...]) instead of (defc [..] (html [:div ...]))

grounded_sage09:03:38

So I just define it the as a defn with the same body as that macro?

grounded_sage09:03:51

and called compile-html?

rauh09:03:02

Yes, correct

rauh09:03:15

Use a macroexand on the defc to verify it works

grounded_sage09:03:34

Will be interesting to see if it works. I ended up using Shadow cljs because I was having issues with the library I am using and npm-deps

grounded_sage09:03:05

Looks like Shadow cljs doesn't like this approach

------ ERROR -------------------------------------------------------------------
 File: jar:file:/Users/wade/.m2/repository/sablono/sablono/0.8.1/sablono-0.8.1.jar!/sablono/core.cljs
Exception: No namespace: sablono.core found
	clojure.core/the-ns (core.clj:4128)
	clojure.core/ns-publics (core.clj:4155)
	clojure.core/ns-publics (core.clj:4155)
	shadow.build.macros/find-macros-in-ns (macros.clj:32)
	shadow.build.macros/find-macros-in-ns (macros.clj:30)
	shadow.build.macros/load-macros (macros.clj:80)
	shadow.build.macros/load-macros (macros.clj:50)
	shadow.build.compiler/post-analyze-ns (compiler.clj:44)