Fork me on GitHub
#reagent
<
2019-02-28
>
kwladyka07:02:22

https://codesandbox.io/s/4990z60 demo.js TransitionComponent={this.state.Transition} which refer to for example

function TransitionRight(props) {
  return <Slide {...props} direction="right" />;
}
How to do it in reagent?
[mui/snackbar
                 {:open true
                  :Transition-component (r/as-element [(r/adapt-react-class mui-core/Slide)
                                                       {:direction "right"}])
                  :style {:position "static"}
                  :anchor-origin {:vertical "bottom"
                                  :horizontal "left"}
                  :key id
                  ;:auto-hide-duration 3000
                  :on-close (fn [_ reason]
                              (when (= "timeout" reason)
                                (re-frame/dispatch [::notifications-events/remove id])))}
                 content]
throw
Warning: Failed prop type: Invalid prop `TransitionComponent` of type `object` supplied to `Snackbar`, expected a component.

kwladyka07:02:35

I was trying with as-component, fn, wrap [] and without etc. No luck.

valtteri09:02:08

@kwladyka try

:Transition-component (r/reactify-component (fn [props] [:> mui-core/Slide props]))
 :Transition-props {... whatever props... }

kwladyka09:02:45

wha the… is reactify-component hmm

kwladyka09:02:00

as-element, as-component - i am confuse 🙂

kwladyka09:02:21

> as-component is now as-element oh as-compontent should be deprecated! I got it.

valtteri09:02:02

Yeah I remember it took some head scratching to get those right. 🙂

kwladyka09:02:58

Do you understand when use as-element vs reactify-component ?

kwladyka09:02:17

I guess I can know this after error in console heh

kwladyka09:02:11

But it looks like if I want to use function in parameters, then I shoudl use reactify-component

valtteri09:02:48

Maybe the easy way to put it is that when the API says a prop should be an element, use as-element and when the API says a prop should be a component, use reactify-component.

kwladyka09:02:22

yeah, the easiest way is to read error messages probably 😉

😉 5
mikerod15:02:50

if not, may help shed some light

kwladyka16:02:16

yes, I read it