reagent

A minimalistic ClojureScript interface to React.js http://reagent-project.github.io/
p-himik 2020-05-11T03:11:42.424400Z

The question was about ratom vs ratom. :) There's an alias in Reagent.

2020-05-11T04:01:13.424600Z

Uggh. Sorry

Eliraz 2020-05-11T11:34:14.425100Z

anyone tried the new `functional-compiler` of reagent? how would I know that Reagent actually creating function components and not Class components? I mean how can I see the React code that comes out ?

Eliraz 2020-05-11T11:39:01.426100Z

Also, using the new functional-compiler how would you use third party libraries? it's all the same as it was?

2020-05-11T13:28:41.428700Z

I'm trying to use react-testing-library with shadow-cljs and am wondering if I should target the :browser-test or :node-test for it. I mean in the React world, jest is obviously not targeting the browser ...

2020-05-12T08:52:27.433700Z

Well, when I try to run it in a browser context, a basic test I ran apparently gets confused with the generated result page, so I was mostly thinking about using it with jsdom. I'll give karma a shot first, though and see if that just works.

2020-05-12T08:52:36.433900Z

Thanks everybody for the input.

2020-05-12T12:05:51.434300Z

And of course it turns out that not react-testing-library was confused but my test and it works as a browser-test just fine.

v 2020-05-11T13:33:54.428800Z

It should be :karma . Here is a build config that I recently used to solve the same problem.

:karma-test
          {:target    :karma
           :output-to "out/karma/test.js"
           :output-dir "out/karma"
           :source-path "karma"
           :compiler-options {:infer-externs :auto}
           :ns-regexp "-test$"}}}

v 2020-05-11T13:35:17.429100Z

Please go through this - https://shadow-cljs.github.io/docs/UsersGuide.html#target-karma

2020-05-11T13:53:27.429300Z

Hmm. I'm under the impression that using Karma actually also involves launching a browser to run the tests. If possible, I would like to avoid this.

v 2020-05-11T14:14:36.429500Z

Nope, you can run in headless mode

thheller 2020-05-11T14:33:03.429700Z

I'm not sure how react-testing-library works but if its meant to run in node then :node-test should be fine

lilactown 2020-05-11T16:10:14.429900Z

react-testing-library does expect to use the DOM; so you’ll want to run it either in a browser context (using :browser-test for local dev and :karma for CI) or in :node-test and provide a DOM polyfill like jsdom: https://github.com/jsdom/jsdom

Mark Wardle 2020-05-11T21:30:12.432Z

I'm sorry if this is such a newbie question, but if I wanted to reagent-ify a google closure component such as DatePicker, how would I do so? I've tried copying the technique in https://github.com/reagent-project/reagent/blob/master/doc/InteropWithReact.md but I get an error react_devtools_backend.js:6 error when calling lifecycle function pc-ward.core/mount-root TypeError: this.getBaseCssClass is not a function at goog.ui.DatePicker (datepicker.js:105) I probably need to learn react and javascript before trying to convert JS examples into cljs! All tips appreciated thank you.

lilactown 2020-05-11T21:58:39.433200Z

@mark354 a google closure component has nothing to do with react, so you’re going to struggle a lot trying to use anything in that document with https://google.github.io/closure-library/api/goog.ui.DatePicker.html

Mark Wardle 2020-05-12T10:06:45.434100Z

Ah I see. Thank you. I assumed the reagent macro did all of the js getElementById and render for an arbitrary component. So essentially I have to create a reagent “form 3” type and run getElementById and render from there into the DOM fragment? Thanks I’ll give this a try.