TypeError: Cannot read property ‘prepareStyles’ of undefined

The issue:

We got into this issue when we were using material-ui of ReactJS. It is a cool library to use that provides useful components with solid design. We were trying to use the autocomplete component of material-ui. As soon as we call the autocomplete component we got into the following issue:

TypeError: Cannot read property 'prepareStyles' of undefined

The reason:

It was missing a wrapper called MuiThemeProvider to get the proper style of it.

The solution:

We had to import the MuiThemeProvider from material-ui and the call it like below:

    <MuiThemeProvider>
        <AutoComplete
            floatingLabelText="Same text, different values"
            onNewRequest={this.handleNewRequest}
            openOnFocus={true}
            dataSource={this.props.stocks}
            dataSourceConfig={this.dataSourceConfig}/>
    </MuiThemeProvider>
Share