Relative Content

Tag Archive for reactjsmouseeventaddeventlistenerreact-state-management

Avoiding endless event listeners that are added when a state changes in React

I have a state-variable items that’s just a collection (object) of items with an ID and a ref (which points to an HTMLDivElement), and a state-variable attachments which is another collection, but has the opacity key that I’ll be changing if an item is ever dragged close to it. So, two states on which I actually depend. Here’s the code for how I’m achieving this: