I am implementing a crop feature with React. When the user right clicks, a context menu appears. In the context menu, a user can select crop item. When a user selects crop, cropping gets activated. Now, I want to close the cropping state when the user clicks outside of that division. How do I have to do react way without DOM manipulation? Or should I have to use DOM manipulations such as add EventListener & removeListener
? What are the cons of using DOM access here? Please let me know this thoroughly since this is going to be implemented in many of the features I am going to develop. For example, the context menu I was talking about, or the dropdown menu.
Here is an example for the reference - Sandbox. Now, when the user clicks outside of ReactCrop
component, I want to close the crop through react way.
I don't want to go ahead with document.addEventListener or removeListener
.