I am trying to implement react-spring
(https://www.react-spring.io/docs/hooks/basics) into my Clojurescript proct and I am struggling to translate this to clojurescript
import {useSpring, animated} from 'react-spring'
function App() {
const props = useSpring({opacity: 1,
from: {opacity: 0}})
return <animated.div style={props}>I will fade in</animated.div>
}
So far this is what I have done: I have required the following:
(:require
[useSpring]
[animated])
and in a let block I have something like so:
(defn example-app []
(let [props (useSpring (->js {:opacity 1
:from {opacity: 0}}))]
(def props props)
[:animated.div {:style props} "I will fade in"]
))
The variable props
returns this :
#js{:opacity #object[AnimatedValue [object Object]]}
Than this is how I render the animated object
(react-dom/render
(hx/f [example-app])
(goog.dom/getElement "example-app"))
This is the error that I get
#object[Error Invariant Violation: Objects are not valid as a React child (found: object with keys {ns, name, fqn, _hash, cljs$lang$protocol_mask$partition0$, cljs$lang$protocol_mask$partition1$}). If you meant to render a collection of children, use an array instead.
in core$example_app]
What am I doing wrong? What am I missing?