Javascript 如何在单独的文件中编写useStyle代码?

Javascript 如何在单独的文件中编写useStyle代码?,javascript,reactjs,material-ui,Javascript,Reactjs,Material Ui,我使用的是const-theme=createMuiTheme({code在单独的文件中,我使用的是所有的useStyle CSS。我如何实现这一点 const theme = createMuiTheme({ palette: { primary: { main: '#157FFB', }, secondary: { main: '#3f51b5', }, }, }); 导出常量主题=…?但我不知道您到底想做什么?但我认为您必

我使用的是
const-theme=createMuiTheme({
code在单独的文件中,我使用的是所有的useStyle CSS。我如何实现这一点

const theme = createMuiTheme({
  palette: {
    primary: {
      main: '#157FFB',
    },
    secondary: {
      main: '#3f51b5',
    },
  },

});

导出常量主题=…
?但我不知道您到底想做什么?但我认为您必须将MuiThemeProvider移动到“主”文件,例如app.js/index.js。因为现在您只有MaterialTable的主题,而不是整个项目的主题。然后,您可以添加makeStyles/useStyles挂钩。
    <MuiThemeProvider theme={theme}>
      <MaterialTable
        title="Styling with MuiThemeProvider Preview"
        columns={[
          {
            title: 'Name', field: 'name',
          },
          { title: 'Surname', field: 'surname' },
          { title: 'Birth Year', field: 'birthYear', type: 'numeric' },
          {
            title: 'Birth Place',
            field: 'birthCity',
            lookup: { 34: 'İstanbul', 63: 'Şanlıurfa' },
          },
        ]}
        data={[
          { name: 'Mehmet', surname: 'Baran', birthYear: 1987, birthCity: 63 },
          { name: 'Zerya Betül', surname: 'Baran', birthYear: 2017, birthCity: 34 },
        ]}
        options={{
          selection: true
        }}
      />
    </MuiThemeProvider>