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

[slider] onMouseDown function is not correctly updated #741

Open
zvakanaka opened this issue Feb 5, 2021 · 2 comments
Open

[slider] onMouseDown function is not correctly updated #741

zvakanaka opened this issue Feb 5, 2021 · 2 comments
Labels
Status: In Progress Type: Bug Something isn't working

Comments

@zvakanaka
Copy link

🐛 Bug report

Current Behavior

Passing a useCallback function to the onMouseDown prop (and the other similar props) keeps the original function around.

Expected behavior

A useCallback function passed to the onMouseDown prop (and other similar props) should be updated when something in the dependency array changes.

Reproducible example

Sample of the issue in CodeSandbox

Your environment

Software Name(s) Version
Reach Package @reach/slider 0.13.0
React react 17.0.1
Browser Firefox 86.0
Assistive tech None None
Node node v14.13.1
npm/yarn yarn 1.21.1
Operating System macOS 10.15.7
@chaance
Copy link
Member

chaance commented Mar 2, 2021

Good catch -- we're probably trying to be a little too clever here since by trying to avoid re-renders internally. That should probably be left to the user in this case. I've patched this up in a sandbox but am anticipating that you might have another problem unless you're trying to get the previous value in your event handler. Haven't merged anything yet because I need to test a few edge cases with these changes: https://codesandbox.io/s/intelligent-ives-0x6rz?file=/src/App.js

@chaance chaance added Status: In Progress Type: Bug Something isn't working labels Mar 2, 2021
@chaance chaance changed the title [Slider] onMouseDown useCallback Function is Not Being Updated [slider] onMouseDown function is not correctly updated Apr 21, 2021
@chaance
Copy link
Member

chaance commented Apr 21, 2021

A note for self: this change will affect all pointer-related events, and we'll want to add notes in the documentation if users want to opt-in to the current behavior after the change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: In Progress Type: Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants