Is there a standard way to utilize React components in Rum?
@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
Plug: With hicada you can do the same [:> ...]
syntax
Oh! I will check that out.
The problem I have is I am actually very interested in doing React Native for Web. So I'm actually not needing Sablono theoretically.
Checkout hicada in this case, there is a few ideas to make RN easier in that case with a special config flag
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
Have you much experience with RN code in cljs? @rauh
Nope, I've just toyed with it a few months ago
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.
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.
Think it has a chance of getting developer mindshare?
It looks like a fantastic project. Just react is so far ahead in this space I'm curious where people think it fits in.
I'd say it has more traction than ReactNative. Tons of great work happening.
Personally I would use Flutter instead of RN for a new project.
Interesting. Even if you were using Cljs?
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
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.
Sorry I'm still a noob with Cljs/Clj. What do you mean by this Rum, simple overwrite the sablono.compiler/compile-html macro.
?
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
It will be picked up instead of the sablono/compiler.clj
file in the sablono jar
ok
@grounded_sage In that case you will have to wrap your defc
bodies in a call to that html
macro.
When using the hack to overwrite sablono you can just write (defc [..] [:div ...])
instead of (defc [..] (html [:div ...]))
So I just define it the as a defn
with the same body as that macro?
and called compile-html
?
Yes, correct
Use a macroexand
on the defc
to verify it works
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
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.
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)