What is the error you're getting? And can you copy + paste how you are requiring the library?
Based on my reading of that README, it does seem to support clojurescript
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?
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.
yes thanks!
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.
I.e. instead of (defn dropdown-raw [props] ...)
it will be (defn dropdown-raw [^js props] ...)
and so on.
You don't need to do that for stuff like className
because you never try to access its fields, you just pass it around.
@p-himik thanks! tried for props
, but didn't help
No clue then. Does that error have any details, any stack trace?
@p-himik well it's mostly just this: https://dpaste.com/5L966STRY
> 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?
BTW no need to @ someone that participates in a thread - we still get notifications. :)
ah good point on @
reagent is 0.10.0
so yes... maybe I can wrap a functional component with classical one (in classical React, haha) and then this will work
I tried js/React.createElement instead of :>
but this didn't help
i.e. also works during development but getting the same error
when compiled
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.
Yes, no luck even when I rewrite everything in JS
I'll try later to figure out when I have time, comparing output of whitespace and simple versions in minimal case