Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
155
rated 0 times [  159] [ 4]  / answers: 1 / hits: 30694  / 9 Years ago, fri, august 21, 2015, 12:00:00

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?


More From » reactjs

 Answers
21

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.


[#65330] Wednesday, August 19, 2015, 9 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
hector

Total Points: 726
Total Questions: 103
Total Answers: 100

Location: Seychelles
Member since Mon, Jun 28, 2021
3 Years ago
;