[UPDATE 2015-06-27] Meteor MDG is changing its skin and now they provide a Meteor + React + Material UI integration example, which is a bit different to the one suggested here.
…however, the link under the word “example” now goes to a 404 error.
Is there currently a correct way to integrate Material UI with Meteor 1.3 beta/React?
They do recommend importing directly from the component for build speed/size efficiency but for prototyping I think just getting them from one place should suffice until you want to optimise
Hey folks.
Just trying out Material UI using your methods here.
I copied your imports above and in my console I get the following error -
warning.js:44 Warning: Failed Context Types: Required context muiTheme was not specified in AppBar.
Check the render method of MainLayout.
My ‘MainLayout’ code is this -
import React from 'react';
import AccountsUI from '../AccountsUI.jsx';
import AppBar from 'material-ui/AppBar';
export const MainLayout = ({content}) => (
<div className="main-layout">
<AppBar
title="Title"
iconClassNameRight="muidocs-icon-navigation-expand-more"
/>
{content}
</div>
)
Yes. You need to do this in your topmost container:
import React from 'react'
import MuiThemeProvider from 'material-ui/styles/MuiThemeProvider'
import getMuiTheme from 'material-ui/styles/getMuiTheme'
import lightBaseTheme from 'material-ui/styles/baseThemes/lightBaseTheme'
const lightMuiTheme = getMuiTheme(lightBaseTheme);
const App = React.createClass({
render(){
return(
<MuiThemeProvider muiTheme={lightMuiTheme}>
<div>
[... rest goes here...]
</div>
</MuiThemeProvider>
)
}
});
They changed that a bit when going from v14 to v15. For some reason, they also insist on not providing infos about breaking changes on their documentation. For that, you have to search the GitHub repo and go through the release notes.
Also, when going through said documentation, make sure that you’re selecting v15-beta.2 in the dropdown as that’s the version you’re likely on if you’re using React@v15
v15 was still in beta as of yesterday (official version number was 0.15.0-beta.2) , but appears to have been accidentally released for automatic download on “npm update material-ui”. It’s because it was still in beta that the docs weren’t updated. Checking just now for purposes of this post, I see the latest version is 0.15.0, so I guess it is now out of beta. Presumably the docs will be updated shortly. I’ve had very good experience using it.
Yes, “accidentally”. I got alpha-1 by “accident” and when I noted this issue on their GitHub page, they told me that it was my own fault for downloading alpha software.
Nevermind that all I did was a mere npm install --save react material-ui
My “topmost” container, if I am getting this right, is this MainLayout, but it seems the way I’ve been doing it with the tutorial looks wacky compared to how most other tutorials/examples I’ve seen do it.
GOT IT!
Here’s my mainlayout now :
import React from 'react';
import AccountsUI from '../AccountsUI.jsx';
import MuiThemeProvider from 'material-ui/styles/MuiThemeProvider';
import getMuiTheme from 'material-ui/styles/getMuiTheme';
import lightBaseTheme from 'material-ui/styles/baseThemes/lightBaseTheme';
import AppBar from 'material-ui/AppBar';
const lightMuiTheme = getMuiTheme(lightBaseTheme);
export const MainLayout = ({content}) => (
<div className="main-layout">
<MuiThemeProvider muiTheme={lightMuiTheme}>
<div>
<AppBar
title="Title"
iconClassNameRight="muidocs-icon-navigation-expand-more"
/>
<main>
{content}
</main>
</div>
</MuiThemeProvider>
</div>
)