Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Show Dialog on React material-ui

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?

like image 943
tinazheng Avatar asked Aug 21 '15 20:08

tinazheng


1 Answers

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.

like image 65
lyosef Avatar answered Oct 07 '22 17:10

lyosef