ClickAwayListener throws error "Cannot update a component (MyComponent
) while rendering a different component"
#21542
Labels
component: ClickAwayListener
The React component
status: waiting for author
Issue with insufficient information
Current Behavior 😯
Since the
onClickAway()
is getting called in the main render function if anysetState
be inside this function we'll get this warning:https://github.com/mui-org/material-ui/blob/4e4ae0e0017dad22166658281b42716114daaef8/packages/material-ui/src/ClickAwayListener/ClickAwayListener.js#L89
(ps: the Popper is not the MuiPopper in this picture, it's customized popper which I used ClickAwayListener inside it)
Expected Behavior 🤔
It should not throw an error.
I suggest to call this function inside an
useEffect
and avoid calling it inside the main function.Context 🔦
I'm trying to use it inside a customized popper.
Your Environment 🌎
The text was updated successfully, but these errors were encountered: