Magrini Bruna
Magrini Bruna

Reputation: 91

How to use a material-ui button with MuiThemeProvider as Popup's trigger in React

I'm trying to use as a trigger of a Popup in React a button with custom theme:

 <PopUp modal trigger={
                        <MuiThemeProvider theme={buttonTheme}>
                            <Button variant="contained" color="secondary">Excluir</Button>
                        </MuiThemeProvider>
 }>

But when I do this, I get this error: "Failed prop type: The following props are not supported: onClick. Please remove them. in ThemeProvider" and "Function components cannot be given refs. Attempts to access this ref will fail. Did you mean to use React.forwardRef()?". I would like to stop the error. The button gets colorful, but it doesn't open the Popup.

Upvotes: 0

Views: 447

Answers (1)

Magrini Bruna
Magrini Bruna

Reputation: 91

You just need to put the tag outside the trigger.

<MuiThemeProvider theme={buttonTheme}>
         <PopUp modal trigger={<Button variant="contained" color="secondary">Excluir</Button>>}
</MuiThemeProvider>

Upvotes: 0

Related Questions