Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize computeMagneticTarget function definition to prevent unecessary re-definitions with React's useEffect hook #2

Open
loucadufault opened this issue Sep 14, 2021 · 0 comments

Comments

@loucadufault
Copy link
Owner

loucadufault commented Sep 14, 2021

put computeMagneticTarget nested function definition as a callback for React's useEffect hook, so that it is only redefined when one of the dependencies change, that is either of the variables magneticBoundaryDeadzone or magneticRadius change between renders.

This is for optimization reasons only.

see https://github.com/loucadufault/MagneticSlider/blob/main/MagneticSlider.js#L36

@loucadufault loucadufault changed the title Optimize function definition Optimize computeMagneticTarget function definition to prevent unecessary re-definitions Sep 14, 2021
@loucadufault loucadufault changed the title Optimize computeMagneticTarget function definition to prevent unecessary re-definitions Optimize computeMagneticTarget function definition to prevent unecessary re-definitions with React's useEffect hook Sep 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant