I have a JS function which I need to run in my React App.
The function adds a mousemove event listener to the 'body' and then mouse-down and mouse-up events to the 'window'. Finally we change the style of an element dependent on the eventListeners.
I really don't know where this function would go, or where it would be imported and used?
From my research two things came up:
"So either you define the method on global scope (aka window). And then you can use it from any methods, being React or not."
How exactly would you do that. Would that be some sort of 'bundle.js' which is included in the index.html file? I already have a webpack.config set up creating a bundle.js for my react components.
"Or you can switch to module based paradigm and use require/import to get the module and use the function."
Ok, but the javascript function in question spans over a few different components? Perhaps I could listen to mouse-move event on "body" but how would i then dynamically style another element in another component?
Thanks a lot for any help?