ethanselzer / react-cursor-position

A React component that decorates its children with mouse and touch coordinates relative to itself.
https://ethanselzer.github.io/react-cursor-position
MIT License
143 stars 35 forks source link

Conditionally enable/disable tracking? #14

Closed Nantris closed 6 years ago

Nantris commented 6 years ago

This is an awesome package and thank you very much for it.

I am using it in a case where I only need to track the cursor in very select circumstances, and I'd love a way to disable the tracking when it's not needed to reduce re-renders.

I can conditionally load it, but that means unmounting and remounting the child components which has some side effects. Is there anything I can do about CPU usage?

Thanks again very much.

ethanselzer commented 6 years ago

Hi @Slapbox - Thanks for your kind words and for your suggestion. I very much appreciate it. Having a disable feature seems like a useful option. I will get to work on it and post back here when it is ready.

Nantris commented 6 years ago

@ethanselzer I'm glad you like the idea and thanks again for the great project and all your work!

ethanselzer commented 6 years ago

@Slapbox - Support for enabling and disabling has landed in v2.3.0. Please give it a try and let me know your thoughts. Thanks!

ethanselzer commented 6 years ago

@Slapbox - I'm going to close this as fixed. Thanks again for opening the issue and raising my awareness to the use case. I really appreciate it. If you find react-cursor-position useful, please consider starring it on GitHub. Starring helps to grow the project, which is good for everyone.

ethanselzer commented 6 years ago

Fixed by v2.3.0