Fork me on GitHub
#fulcro
<
2022-09-23
>
sheluchin11:09:16

Is there a better way to set some properties on a JS object when using react-factory? I'm trying to spread the defaultProps into the props that I'm setting manually.

<Highlight {...defaultProps} code={exampleCode} language="css">
I would think I can do something like (merge (js->clj defaultProps) {:code "p {}" :language "css"}) but converting it to a cljs map blows the stack with RangeError: Maximum call stack size exceeded. I can make it work with (set! (.-language defaultProps) "css") but I'm wondering if I can work with maps instead of using js property access interop.

sheluchin17:09:24

I figured out a way around this. defaultProps only had two keys and I just made my own cljs map with those keys and some others. I do still wonder why it was blowing the stack with RangeError but I can get by.

sheluchin19:09:32

@U0522TWDA Thank you for the thread. That was a good read. Slightly disappointing to see that there aren't really any solutions, but awareness is better than its opposite. I'm glad that I didn't go too far down the rabbithole on this one and found a solution to my problem fairly quickly, but the thread is a good cautionary tale.

👍 1