Fork me on GitHub
#reagent
<
2017-08-04
>
fabrao02:08:57

@juhoteperi worked with :data-uk-*, thanks a lot

kaosko06:08:39

so how do I debug a (reagent-based) site that spits out a js error in production but works perfectly in development mode? (app.js:1352 Uncaught TypeError: b.Xh is not a function)

gadfly36106:08:52

@kaosko that likely is from a missing extern

gadfly36106:08:07

Are you using any javascript libs from your cljs?

kaosko07:08:55

thanks @gadfly361, yes makes sense. uh not too many, but I'm trying to make mine a PWA and the service worker file is in plain js.

kaosko07:08:15

oh and there's another one. clipboard.js via cljsjs..

kaosko07:08:49

how do I configure externs?

gadfly36107:08:27

@kaosko Any time you use a javascript method or object name within clojurescript, the google closure compiler could potentially munge the name, so like (.fooBar ....) could get renamed to b.Xh. So if you call anthing from that plain js file in cljs, you still may need to add an extern. As far as a package via cljsjs, sometimes there are missing externs too. To add externs, first go to the clojurescript build in your project.clj

:cljsbuild {:builds [{:id "prod"
                        :source-paths ["src/cljs"]
                        :compiler {:output-to "resources/public/js/compiled/app.js"
                                   :optimizations :advanced
                                   :pretty-print false
                                   :externs ["externs.js"]}}]})  ;; < -- add this

kaosko07:08:58

actually from the stack trace, I think this is the line: pt (.createSVGPoint svgnode)

gadfly36107:08:22

then create an externs.js file in the root of your project's directory. then add externs to that file, for example

var $ = function(){};

gadfly36107:08:31

oh good, knowing what is causing the error can help make the process a lot faster

gadfly36107:08:11

gotta run for now, but good luck!

kaosko07:08:46

thanks @gadfly361!

dimovich18:08:25

I can force component to re-mount by changing its ^{:key...}

dimovich18:08:17

is there a more idiomatic way?...

dimovich18:08:51

it's working ok for now, but I don't know if it's the right way to handle that

jfntn19:08:44

@metametadata ah I almost had that but was just returning the ratom, why is the reaction necessary?

metametadata19:08:08

in that context I wanted to be really strict about the type 🙂

metametadata19:08:20

mutating the ratom would make no sense

metametadata19:08:50

so it would be better to throw an error if user tries to mutate the returned object

metametadata19:08:18

(reaction is read-only)

jfntn19:08:18

Ah good point!

jfntn19:08:31

Is there another way to directly interface with a reaction, setting its new value like watches would do?

pesterhazy20:08:55

@dimovich that's a workaround... more idiomatic would be to use lifecycle methods properly to achieve what you want to do

dimovich21:08:58

@pesterhazy thanks

metametadata23:08:16

@jfntn there could be some low-level/private API.. What's the use case?

jfntn23:08:24

Same use-case really, but would like to minimize the performance overhead since the atom is updated a lot

metametadata23:08:46

@jfntn 1) Maybe it's not really a problem as no data is really copied on updating the ratom which watches after an atom? 2) I also don't think there's a way to get less "notifications" from the atom. Otherwise, the produced ratom/reaction can "miss" state updates.