react

"mulling over state management stuff"
martinklepsch 2021-03-29T19:01:04.048700Z

Here’s my Rum React Spring API wrapper:

(ns icebreaker.components.animations
  (:require [rum.core :as rum]
            ["react-spring" :as rs]))

(rum/defc AnimatedDiv < rum/static
  [style child]
  (js/React.createElement rs/animated.div (clj->js style) child))

(defn use-spring
  [config-map]
  (rs/useSpring (clj->js config-map)))
😂

lilactown 2021-03-29T19:02:18.048900Z

seems good!

martinklepsch 2021-03-29T19:07:16.049500Z

I think this requires that child is a react component, i.e. it can’t be hiccup but that is fine for my immediate needs

martinklepsch 2021-03-29T19:07:29.049700Z

also put it in a gist here: https://gist.github.com/martinklepsch/0cc942365e472671eee2ad5a363c34e7

martinklepsch 2021-03-29T19:07:37.050Z

+ some example usage

lilactown 2021-03-29T19:26:11.050500Z

yeah, you could probably parse child in the body of AnimatedDiv if you wanted