clojurescript

ClojureScript, a dialect of Clojure that compiles to JavaScript http://clojurescript.org | Currently at 1.10.879
Alex 2021-01-17T04:48:02.044100Z

What is the error you're getting? And can you copy + paste how you are requiring the library?

Alex 2021-01-17T04:48:26.044300Z

Based on my reading of that README, it does seem to support clojurescript

andrewboltachev 2021-01-17T17:18:51.048500Z

Hello! I'm creating a regaent component which uses hooks (using Popper.js library): https://dpaste.com/6VL9ZMBCQ using Figwheel-main and want to use advanced optimization. React is provided via foreign-libs. When having optimization level higher than whitespace, I'm getting "Invalid hook call" error. How can I tell the exact reason of it? Or how can I prevent (in CLJS) certain functions from being optimized maybe?

ingesol 2021-01-18T10:39:48.054200Z

Don't know if it's relevant, but you can set :pretty-print and `:pseudo-names` to true in compiler options, that will give you a much more readable and debuggable advanced build.

andrewboltachev 2021-01-18T12:42:19.055Z

yes thanks!

p-himik 2021-01-17T17:47:14.048900Z

Try adding ^js in front of every new binding, be it in let or fn, that stores a JS object whose fields you're getting via interop.

p-himik 2021-01-17T17:47:38.049100Z

I.e. instead of (defn dropdown-raw [props] ...) it will be (defn dropdown-raw [^js props] ...) and so on.

p-himik 2021-01-17T17:48:23.049300Z

You don't need to do that for stuff like className because you never try to access its fields, you just pass it around.

andrewboltachev 2021-01-17T17:56:32.049500Z

@p-himik thanks! tried for props, but didn't help

p-himik 2021-01-17T18:00:40.049700Z

No clue then. Does that error have any details, any stack trace?

andrewboltachev 2021-01-17T18:09:56.049900Z

@p-himik well it's mostly just this: https://dpaste.com/5L966STRY

p-himik 2021-01-17T18:14:06.050100Z

> Hooks can only be called inside of the body of a function component. Well, this is quite telling. Maybe Reagent has issues with optimizations and its workaround for creating functional components with :>. Are you using Reagent 1.0+ by any chance?

p-himik 2021-01-17T18:14:27.050300Z

BTW no need to @ someone that participates in a thread - we still get notifications. :)

andrewboltachev 2021-01-17T18:25:24.050500Z

ah good point on @

andrewboltachev 2021-01-17T18:25:29.050700Z

reagent is 0.10.0

andrewboltachev 2021-01-17T18:27:07.050900Z

so yes... maybe I can wrap a functional component with classical one (in classical React, haha) and then this will work

andrewboltachev 2021-01-17T18:38:35.051100Z

I tried js/React.createElement instead of :> but this didn't help

andrewboltachev 2021-01-17T18:39:15.051300Z

i.e. also works during development but getting the same error

andrewboltachev 2021-01-17T18:39:29.051500Z

when compiled

p-himik 2021-01-17T19:04:35.051900Z

No idea, sorry. You can direct this particular question to #reagent since its maintainers have higher chances of seeing your question there. Or, since it looks like a proper usage according to the documentation, you can just create an issue on Reagent's GitHub.

andrewboltachev 2021-01-17T19:21:40.052100Z

Yes, no luck even when I rewrite everything in JS

andrewboltachev 2021-01-17T19:23:55.052300Z

I'll try later to figure out when I have time, comparing output of whitespace and simple versions in minimal case

👍 1