Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use with reagent? #40

Closed
cjohansen opened this issue Sep 21, 2017 · 3 comments
Closed

How to use with reagent? #40

cjohansen opened this issue Sep 21, 2017 · 3 comments

Comments

@cjohansen
Copy link

I tried using this with reagent with little luck. The following works as expected:

(ns myapp.core
  (:require [cljsjs.material-ui]
            [cljs-react-material-ui.core :as ui]
            [cljs-react-material-ui.icons :as ic]
            [reagent.core :as r]))

(defn component []
  (ui/mui-theme-provider
   {:mui-theme (ui/get-mui-theme)}
   (ui/paper "Hello world")))

(r/render (component) (js/document.getElementById "app"))

But this fails spectacularly:

(ns myapp.core
  (:require [cljsjs.material-ui]
            [cljs-react-material-ui.core :as ui]
            [cljs-react-material-ui.icons :as ic]
            [reagent.core :as r]))

(defn component []
  [ui/mui-theme-provider
   {:mui-theme (ui/get-mui-theme)}
   [ui/paper "Hello world"]])

(r/render (component) (js/document.getElementById "app"))

Tested with cljs-react-material-ui 0.2.48 and React 15.6.1-1 and 16.0.0-beta.5-1. In both cases I get a bunch of exceptions:

  • "Failed prop type: Invalid prop children of type object supplied to MuiThemeProvider, expected a single ReactElement"
  • "react-dom.inc.js:18118 Uncaught Error: MuiThemeProvider.render(): A valid React element (or null) must be returned. You may have returned undefined, an array or some other invalid object"

Am I holding it wrong?

@njordhov
Copy link

Use cljs-react-material-ui.reagent/mui-theme-provider instead of cljs-react-material-ui.core/mui-theme-provider.

@njordhov
Copy link

njordhov commented Sep 22, 2017

Looks like the fix is in with PR #38.

@cjohansen
Copy link
Author

D'OH! That was lazy of me. Thanks!

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants