nrako / react-component-resizable

A React component to implement cross-browser event based resize detection
MIT License
70 stars 16 forks source link

Adding disable props #16

Closed blackrabbit99 closed 7 years ago

blackrabbit99 commented 8 years ago

Don't you think that it would be great enhancement to add disable prop to prevent listening to changing of some nodes' size ?

<Resizable onResize = {this.sizeChanged} className='myClass' disable })}>

<Resizable onResize = {this.sizeChanged} className='myClass' disable=false })}>
nrako commented 8 years ago

Hi @blackrabbit99, what would be the benefits over the following?

sizeChanged: function(resizeAttributes){
  if (this.stateOrProps.disableResizeListening) return;
  // ...
}
blackrabbit99 commented 8 years ago

Prevention of any computation behind the component. Sample: I got 20 components where I want to handle resize callback but only one concurrent that i'm interested in.

blackrabbit99 commented 8 years ago

I mean vanilla implementation has attach and remove flow. So I guess it would be great to add the flow in the react component

nrako commented 8 years ago

I like to keep things light (minimal surface-api), specially if I have to maintain it (while not using it anymore), I'll have to thrust you that computation represent a perf (right?) issue with many components since I will not test this anytime soon. So anyway I'm always open for a PR, so if you are sure of the added-value I invite you to fork the repo and implement what you have in mind, even if I don't merge your PR you can still use your fork, MIT license powa ;)