4
import { createMuiTheme, ThemeOptions } from '@material-ui/core/styles';

const theme = (options: ThemeOptions) => {
    return createMuiTheme({
        palette: {
            primary: {
                main: '#b5ddd1'
            },
            secondary: {
                main: '#b2d9ea'
            },
        },
        typography: {
            fontFamily: 'Raleway, Arial',
            button: {
                fontStyle: 'italic',
            },
        },
        ...options,
    })
}

provider

import { ThemeProvider } from '@material-ui/core/styles'

         <Provider store={store}>
            <ConnectedRouter>
                <ThemeProvider theme={theme}>
                    <GlobalStyles/>
                    {/*<ErrorBoundary>*/}
                    {/*<Layout>*/}
                    <Component {...pageProps} />
                    {/*</Layout>*/}
                    {/*</ErrorBoundary>*/}
                </ThemeProvider>
            </ConnectedRouter>
        </Provider>
import Button from '@material-ui/core/Button'

            <div>
                <div>Log into APP</div>
                <Button>Test</Button>
            </div>

But I am still getting error in Button.js

at styles (/Users/filipbrezina/Documents/Projekty/sportee-frontend/node_modules/ material-ui/core/Button/Button.js:33:78

Can someone help me please? I don't know what am I doing wrong 😏

1
  • Can you please add codesandbox URL so that we can help you debug the issue. Commented May 11, 2020 at 16:08

1 Answer 1

4

There is an error in the way you are defining / providing the theme:

You need to provide it like this:

<ThemeProvider theme={theme({})}> {/* function call: theme({}) */}

Or if you define it like this:

const theme = createMuiTheme({
  palette: {
    primary: {
      main: '#b5ddd1',
    },
    // you can add more options
  }
})

you can provide it this way:

<ThemeProvider theme={theme}>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.