Fork me on GitHub
#reagent
<
2018-12-09
>
bravilogy14:12:10

has anyone ever worked with react-spring? in clojurescript / reagent? I’m basically trying to use its Transition component. the usage in jsx is this

<Transition
  items={items} keys={item => item.key}
  from={{ transform: 'translate3d(0,-40px,0)' }}
  enter={{ transform: 'translate3d(0,0px,0)' }}
  leave={{ transform: 'translate3d(0,-40px,0)' }}>
  {item => props =>
    <div style={props}>{item.text}</div>
  }
</Transition>
it has 2 closure functions as children. so I’m trying to replicate the above like so
[:> spring/Transition {:items items
                            :keys  :email
                            :from  {:transform "translate3d(0, -40px, 0)"}
                            :enter {:transform "translate3d(0, 0px, 0)"}
                            :leave {:transform "translate3d(0, -40px, 0)"}}
      (fn [player]
        (fn [props]
          (reagent/as-element [:div "hello"]))]
(edited) but it throws an error saying it can’t render a function
Functions are not valid as a React child. This may happen if you return a Component instead of <Component /> from render. Or maybe you meant to call this function rather than return it.

juhoteperi14:12:18

@bravilogy maybe (fn [player] (r/reactify-component (fn [props] [:div "hello"])))

juhoteperi14:12:59

Though I'm not sure how this would be different to providing component as fn and using as-element

bravilogy14:12:45

it turns out I was using react-spring 5.9 and when I upgraded to 6, it started working

juhoteperi15:12:32

Yeah, changelog mentions version 6 changed the API