I try to set up the Gatsby kit and deep in react with this site generator and material ui framework. What did I mess? I've got the error:
Cannot read property 'prepareStyles' of undefined
at RaisedButton.render
I installed material ui with npm
npm install material-ui
After add the to components to my post index.js and MyAwesomeReactComponent.js
import React from 'react';
import ReactDOM from 'react-dom';
import MuiThemeProvider from 'material-ui/styles/MuiThemeProvider';
import MyAwesomeReactComponent from './MyAwesomeReactComponent';
const MaterialUiWrapper = () => (
<MuiThemeProvider>
<MyAwesomeReactComponent />
</MuiThemeProvider>
);
export default MaterialUiWrapper
exports.data = {
title: "Material UI ",
date: "2017-12-09T12:40:32.169Z",
}
MyAwesomeReactComponent.js
import React from 'react';
import RaisedButton from 'material-ui/RaisedButton';
const MyAwesomeReactComponent = () => (
<RaisedButton label="Default" />
);
export default MyAwesomeReactComponent;
And add the React-Tap-Event-Plugin to listen for touch events to the root html.js
import injectTapEventPlugin from 'react-tap-event-plugin'
injectTapEventPlugin();
You should enable CSS modules on material-ui CSS in node_modules directory, by default CSS modules are only enabled on files with .module in their path if I remember it right, so you should override the WebPack config,
use
material-ui working with `gatsby' before a couple of months, so it's totally possible.I've just re run my npm build, and all correct now. without any changes.
@ghost all those links are dead, got any updated how do you "enable CSS modules"
something.module.css