Fork me on GitHub
#clojurescript
<
2019-08-12
>
kah0ona10:08:41

Hello, what is the latest best way to use a React component in Reagent? I think I’ve read something about it being improved?

kah0ona10:08:50

Or do I need webpack etc.

kah0ona10:08:05

(Leiningen based figwheel-main project )

kah0ona10:08:00

Hmmm might’ve asked a bit too quickly, but I reckon (.createFactory js/React js/TheComponent) would work

alpox10:08:20

@kah0ona [:> js/TheComponent] should do the trick although I don't know about figwheel-main - i'm using shadow-cljs

kah0ona10:08:23

is that the reason you use shadow-cljs btw? i see people switching a lot

kah0ona10:08:34

aside question: why use shadow-cljs over figwheel?

mccraigmccraig12:08:33

for me, 3 reasons:

mccraigmccraig12:08:59

[1] straightforward consumption of npm deps, without cljsjs

mccraigmccraig12:08:24

[2] build reports detailing the contribution of namespaces to javascript output size, which gives the information required for

mccraigmccraig12:08:59

[3] straightforward splitting of a codebase into modules which can be loaded separately

Iwo Herka11:08:41

@kah0ona I tried both but shadow-cljs presented less problems for me with Vim so I stayed with it. Does figwheel have any particular edge over shadow-cljs?

kah0ona12:08:53

not sure, only have experience with figwheel

kah0ona12:08:23

btw: i was purely looking at live reloading aspect of things, maybe shadow-cljs does more

kah0ona12:08:36

but probably the answer is that they can co-exist 🙂

kah0ona12:08:44

How can I do the following using cljs interop? I've got js/DatePicker working (react-datepicker), but now I want to add a Locale.

mccraigmccraig13:08:00

since you are already shadow-curious, i'll just put this here 😬: https://shadow-cljs.github.io/docs/UsersGuide.html#_using_npm_packages

kah0ona12:08:18

(using leiningen + figwheel-main and i use cljsjs package for react-datepicker)

Roman Liutikov12:08:20

@kah0ona common approach is to bundle js deps with webpack and export everything you need into window object, and connect js bunlde as foreign-library

kah0ona15:08:19

thanks, this is how i did it previously as well indeed, but i wondered if there were more elegant ways nowadays. thanks!

alpox14:08:47

@kah0ona just to give you an idea what this would look like with shadow-cljs:

(ns xyz
  (:require ["react-datepicker" :default DatePicker :refer [registerLocale]]
            ["date-fns/locale/en-GB" :default enGB]))

(registerLocale "en-GB" enGB)

👍 8
alpox14:08:28

(Streight from npm with npm install --save react-datepicker etc.)

alpox14:08:49

This answers also the question of why I chose shadow-cljs over figwheel (one of the reasons)

👍 4
kah0ona15:08:15

cool. yeah this seems a good reason of existence at all for shadow-cljs. Is the live reloading workflow as cool as figwheel’s?

alpox16:08:19

I dont know how it works out for figwheel but i found the live reloads to be awesome in shadow-cljs. No complaints so far and you even get a web interface to force trigger compilations etc.

David Pham18:08:28

I also find shadow-cljs to be really beginner friendly.

Schmoho18:08:34

Hey I am currently experiencing some trouble with re-frisk, maybe someone knows something about it, docs are really sold on "just works". It doesn't load or get shipped. Neither 0.5.4.1 nor 0.5.3, it's in lein :compiler :preloads, same for Firefox and Chromium, and there is just no code in the site. I am using figwheel too. Is there something I am missing?

Schmoho19:08:14

Yeah well nevermind me, I just expected it to pop up at the top.

Libor Danek21:08:44

Hi. I'm literally doing my first steps with clojurescript (and clojure). I'm working through modern-cljs tutorial no. 1 https://github.com/magomimmo/modern-cljs/blob/master/doc/second-edition/tutorial-01.md Following exception is thrown during boot project compilation.

$ boot cljs
...
java.lang.ClassNotFoundException: javax.xml.bind.DatatypeConverter
clojure.lang.Compiler$CompilerException: java.lang.ClassNotFoundException: javax.xml.bind.DatatypeConverter, compiling:(cljs/closure.clj:1:1)
clojure.lang.ExceptionInfo: java.lang.ClassNotFoundException: javax.xml.bind.DatatypeConverter, compiling:(cljs/closure.clj:1:1)
Has anyone encountered this error? What am I doing wrong?
$ boot --version
#
#Mon Aug 12 23:04:29 CEST 2019
BOOT_VERSION=2.8.3
BOOT_CLOJURE_VERSION=1.8.0
BOOT_CLOJURE_NAME=org.clojure/clojure

$ java --version
openjdk 12.0.2 2019-07-16
OpenJDK Runtime Environment (build 12.0.2+10)
OpenJDK 64-Bit Server VM (build 12.0.2+10, mixed mode)
Let me know if I can provide any other relevant info.

thheller21:08:40

@lbrdnk that tutorial is kinda old and assumes you are using Java8. Since you are using Java12 you probably need to update some dependencies

thheller21:08:20

it might be enough if you just add [javax.xml.bind/jaxb-api "2.3.1"] which should provide the missing DatatypeConverter

Libor Danek21:08:09

Thank you. It works now 🙂

Phil MacEachron05:03:07

Thank you as well! This helped me just now.