Problems with webpack configuration - Material-UI decorator
See original GitHub issueI am trying to use different npm modules (Material-ui, etc) , but they don’t seem load properly.
The error message I get is:
Cannot read property 'prepareStyles' of undefined
TypeError: Cannot read property 'prepareStyles' of undefined
at RaisedButton.render (webpack:///~/material-ui/RaisedButton/RaisedButton.js:273:48)
at ReactCompositeComponentWrapper._renderValidatedComponentWithoutOwnerOrContext (webpack:///~/react/lib/ReactCompositeComponent.js:808:34)
at ReactCompositeComponentWrapper._renderValidatedComponent (webpack:///~/react/lib/ReactCompositeComponent.js:835:34)
at ReactCompositeComponentWrapper.performInitialMount (webpack:///~/react/lib/ReactCompositeComponent.js:372:30)
at ReactCompositeComponentWrapper.mountComponent (webpack:///~/react/lib/ReactCompositeComponent.js:260:21)
at Object.mountComponent (webpack:///~/react/lib/ReactReconciler.js:47:35)
at ReactDOMComponent.mountChildren (webpack:///~/react/lib/ReactMultiChild.js:240:44)
at ReactDOMComponent._createInitialChildren (webpack:///~/react/lib/ReactDOMComponent.js:698:32)
at ReactDOMComponent.mountComponent (webpack:///~/react/lib/ReactDOMComponent.js:523:12)
at Object.mountComponent (webpack:///~/react/lib/ReactReconciler.js:47:35)
I am using Meteor, hence the only Webpack configuration I have is the one for Storybook:
//Webpack configuration
const path = require('path');
module.exports = {
module: {
loaders: [
{
test: /\.css?$/,
loaders: [
'style', 'raw'
],
include: path.resolve(__dirname, '../')
}
]
},
resolve: {
extensions: [
'', '.js', '.jsx'
]
}
};
Here is the story:
import React from 'react';
import {storiesOf, action} from '@kadira/storybook';
import {setComposerStub} from 'react-komposer';
import FileUploader from '../file_uploader.jsx';
storiesOf('core.FileUploader', module).add('default view', () => {
return (<FileUploader/>);
})
Here is the component:
import React from 'react';
import DropZone from 'dropzone';
import {RaisedButton, FontIcon} from 'material-ui';
class FileUploader extends React.Component {
constructor(props) {
super(props);
}
render() {
const {imageFiles} = this.props;
return (
<div>
<DropZone className="drop-zone">
<RaisedButton label="Upload Pictures" icon={<FontIcon className="fa fa-upload"/>}/>
<p>
<small>Drop here the product pictures in
<code>jpeg</code>
or
<code>png</code>
format, with size less or equal to 2MB</small>
</p>
</DropZone>
<div className="image-preview">
{imageFiles && imageFiles[0]
? imageFiles.map((image) => {
return (
<div className="image-wrapper"><img src={image.preview
? image.preview
: image.link()}/></div>
);
})
: <div>
<i className="fa fa-camera"></i>{' Preview Images'}</div>}
</div>
</div>
);
}
}
export default FileUploader;
What I am missing?
Issue Analytics
- State:
- Created 7 years ago
- Comments:9 (2 by maintainers)
Top Results From Across the Web
Problems with webpack configuration - Material-UI decorator
I am trying to use different npm modules (Material-ui, etc) , but they don't seem load properly. The error message I get is:...
Read more >React + Material UI + Typescript + Webpack + SSR not ...
Everything was working fine until I tried to add Material UI to it. My directory structure is this: app/ build/ * This is...
Read more >Integrate Material UI + Adjust Webpack: Building a ... - YouTube
Hello everyone! In this video, we integrate a UI library into our application and extend the Webpack configuration to allow loading of css ......
Read more >Troubleshooting - Material UI
This document covers known issues and common problems encountered when migrating from Material UI v4 to v5.
Read more >How to use ReactJS with Webpack 4, Babel 7, and Material ...
Before we go ahead and start messing with the Webpack config file, let's first install some stuff that we are going to need...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@arunoda nice!
@PolGuixe you can work like this.
That’s because of calling injectTapEventPlugin(); on each re-render. Just wrap it with try/catch.