TypeError: Cannot read property 'prepareStyles' of undefined

醉酒当歌 提交于 2019-12-04 22:19:14

You need to wrap your table in a MuiThemeProvider tag

like:

import MuiThemeProvider from 'material-ui/styles/MuiThemeProvider'

const TransactionList = ({transactions}) => {
  return (
    <MuiThemeProvider>
      <Table>
...
      </Table>
    </MuiThemeProvider>
  );
};

If we follow the instructions in the order presented in the Material UI wesite, we can find the solution right there i.e. in the Usage section. They have declared the pre requisite of defining the theme as a Provider, prior to any component usage. These themes can also be customized.

http://www.material-ui.com/#/get-started/usage

Clearly stated with snippet -

import React from 'react';
import ReactDOM from 'react-dom';
import MuiThemeProvider from 'material-ui/styles/MuiThemeProvider';
import MyAwesomeReactComponent from './MyAwesomeReactComponent';

const App = () => (
  <MuiThemeProvider>
    <MyAwesomeReactComponent />
  </MuiThemeProvider>
);

ReactDOM.render(
  <App />,
  document.getElementById('app')
);
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!