react

"mulling over state management stuff"
martinklepsch 2021-04-09T19:27:51.052500Z

I’ve been playing with https://stitches.dev/ a little bit but I can’t quite figure out how to use their styled helper in a way that works with plain CLJS args.

(defn styled [dom-node m]
  (let [react-comp (.styled stitches (name dom-node) (clj->js m))]
    (fn styled-comp-wrapper [attrs child]
      (rum/adapt-class react-comp attrs child))))
Curious if this might be easier with something like #helix but I guess it would be similar?

lilactown 2021-04-09T20:04:16.052800Z

what happens when you use that code you posted?

lilactown 2021-04-09T20:05:53.053600Z

what's the reason for wrapping the adapt-class in another fn?

martinklepsch 2021-04-09T20:21:49.054300Z

@lilactown the reason for the other fn is that I need to pass attrs and children to adapt-class

martinklepsch 2021-04-09T20:24:07.055Z

Interestingly this all works when passing nil as attrs but when I pass anything as an attribute I get Objects are not valid as a React child

lilactown 2021-04-09T22:54:49.055300Z

this looks relevant: https://github.com/tonsky/rum/blob/0.12.3/src/rum/core.clj#L456-L458

lilactown 2021-04-09T22:55:27.056Z

it looks like if you don't pass a map literal to adapt-class as the second argument, it assumes it's a child component

lilactown 2021-04-09T23:04:24.057500Z

I would open up an issue on Rum to get the best advice, but I think you could try something like:

(js/React.createElement react-comp (daiquiri.interpreter/attributes attrs) child)