-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Use forwardRef #10825
Comments
@lazee Calling imperative methods for controlling elements is a discouraged pattern in React. I would encourage you to use an
It's because the Let's see if we can use |
@oliviertassinari Thank you so much for taking the time to answer something that was already documented. I actually looked for it on the site, but must have done a terrible job. My bad. I did realize that I was using an anti-pattern, but couldn't figure out why it didn't work. With other wrapper from other frameworks I haven't had the same issues. But what you say about "exposing a different component" makes sense. I will rewrite and use property instead.
AND: Thank you for Material UI. Love it! |
Let's wait and see how these libraries solve the problem: |
|
@alimo You are right, having following the threads of #10825 (comment). It seems that bringing
|
Hi,
It seems that all component functions are "hidden" when exported through the
withStyles
method.Expected Behavior
Given a component App, using component MainDrawer that have a function toggleDrawer. When setting
ref
attribute on the use of MainDrawer (<MainDrawer ref={(drw) => { this.mainDrawer = drw; }} />
) inside the render method in App, I should be able to callthis.mainDrawer.toggleDrawer()
inside component App.Current Behavior
When dumping
this
in component App I see the mainDrawer component that was added. But it doesn't contain the toggleDrawer function for some reason. If i remove thewithStyles
wrapper from component MainDrawer, then the toggleDrawer function appears in this.mainDrawer and can be executed.The error I get in console is:
This leads me to expect that something is going on in
withStyles
, that leads this function to be hidden? Or maybe I have misunderstood it all.Steps to Reproduce (for bugs)
https://github.com/lazee/material-ui-issue-withstyles
Your Environment
The text was updated successfully, but these errors were encountered: