我正在尝试将react-spring
(https://www.react-spring.io/docs/hooks/basics)实施到我的 Clojurescript proct 中,我正在努力将其翻译为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>
}
到目前为止,这就是我所做的:我需要以下内容:
(:require
[useSpring]
[animated])
在 let 块中我有这样的东西:
(defn example-app []
(let [props (useSpring (->js {:opacity 1
:from {opacity: 0}}))]
(def props props)
[:animated.div {:style props} "I will fade in"]
))
变量props
返回:
#js{:opacity #object[AnimatedValue [object Object]]}
这就是我渲染动画对象的方式
(react-dom/render
(hx/f [example-app])
(goog.dom/getElement "example-app"))
这是我得到的错误
#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]
我究竟做错了什么?我错过了什么?