Skip to content
Advertisement

How can I make a reusable component for Material-UI Snackbar?

I have this Alert component to be used just to have a message that says “Successfully submitted” and I’m trying to use thin in a parent component. However, nothing shows in the parent component.

AlertComponent

JavaScript

Parent Component

JavaScript

How can I fix this? Thank you.

Advertisement

Answer

Although @Ghader Salehi commented already the solution but if anyone is not sure how to control the alert from parent here is the code.

AlertComponent.js

JavaScript

Parent Component (In my code-sandbox I used App.js)

JavaScript
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement