This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-09-23
Channels
- # announcements (8)
- # babashka (12)
- # babashka-sci-dev (6)
- # beginners (62)
- # biff (5)
- # calva (4)
- # cider (2)
- # clj-commons (8)
- # clj-kondo (17)
- # clj-yaml (40)
- # clojars (3)
- # clojure (117)
- # clojure-europe (122)
- # clojure-nl (5)
- # clojure-norway (20)
- # clojurescript (10)
- # consulting (1)
- # datomic (65)
- # events (15)
- # figwheel (1)
- # fulcro (4)
- # lsp (15)
- # mount (15)
- # music (1)
- # off-topic (53)
- # polylith (12)
- # releases (3)
- # shadow-cljs (13)
- # sql (1)
- # test-check (8)
- # xtdb (31)
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.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.
I struggled with similar problems, see https://clojureverse.org/t/is-typescript-better-than-clojurescript-for-interop-heavy-react-apps/9056
@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.