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

Hi, did somebody get withMobileDialog from material ui working with a reagent component?I just cannot get it working, no matter which combination I try.

sveri08:09:54

I get the "functions are not valid as react child. this may happen if you return Component instead of <Component /> from render" error. But how would I wrap a component into the withMobileDialogcomponent?

sveri08:09:37

To add some more context. In plain javascript you would do this:

export default withMobileDialog()(ResponsiveDialog);
where ResponsiveDialog is a react component.

pesterhazy08:09:48

try

(def responsive-dialog* (r/reactify-component responsive-dialog))
[:> ((withMobileDialog) responsive-dialog*) {:prop :go-here}]

pesterhazy08:09:24

assuming that responsive-dialog-dialog is a Reagent component

valtteri08:09:27

@pesterhazy was faster. ๐Ÿ™‚ Was just going to paste this here:

(defn my-dialog [{:keys [fullScreen]}]
  [mui/dialog {:open       true
               :fullScreen fullScreen}
   [mui/typography "Some content"]])

(def with-mobile-dialog (.withMobileDialog js/MaterialUI))

(defn my-view []
  [:> (with-mobile-dialog (r/reactify-component my-dialog))])

valtteri08:09:21

Where mui/dialog is MaterialUI dialog wrapped with adapt-react-class. You could use :> syntax as well

sveri08:09:04

@valtteri @pesterhazy that did it, thank you both ๐Ÿ™‚

๐Ÿ‘ 12