I'm using material-ui's Dialog component for my React application. How do I set my component to a variable so that I can call the onShow()
method?
When adding the Dialog
component, just add a ref to it (ref="dialog"
for example):
<Dialog ref="dialog" title="..." actions="...">
dialog content
</Dialog>
And then you can reference it from your owner component code by using this.refs.dialog.onShow(...)
.
The Dialog component page actually uses refs behind the scenes, as you can see from its source code.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With