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

How to get value of slider in onChange handler? #2978

Closed
jmjpro opened this issue Jan 19, 2016 · 9 comments
Closed

How to get value of slider in onChange handler? #2978

jmjpro opened this issue Jan 19, 2016 · 9 comments
Labels
component: select This is the name of the generic UI component, not the React module! docs Improvements or additions to the documentation

Comments

@jmjpro
Copy link

jmjpro commented Jan 19, 2016

The SyntheticMouseEvent sent to the onChange handler has a target of div. That div doesn't contain the hidden element used to hide the slider value. As such, there doesn't seem to be a normal way to access the slider value in the event handler, which I need to do to update my state. Do I have to resort to refs?

@oliviertassinari oliviertassinari added the docs Improvements or additions to the documentation label Jan 19, 2016
@oliviertassinari
Copy link
Member

That's related to #2957 and #2883.

@jmjpro
Copy link
Author

jmjpro commented Jan 19, 2016

@oliviertassinari, you're not saying this is only a documentation issue are you? Is there some way I can use Slider as-is to get the value?

@oliviertassinari
Copy link
Member

Can't you use the second parameter? I think that the callback looks like this: onChange(event, value).

@jmjpro
Copy link
Author

jmjpro commented Jan 19, 2016

yes got it now. thanks!

@jmjpro
Copy link
Author

jmjpro commented Jan 19, 2016

FYI neither the event nor the value includes the field name so I have to pass that the name as yet another param :-(

@oliviertassinari
Copy link
Member

I have to pass that the name as yet another param

Indeed, why is this bad?

@mbrookes
Copy link
Member

@jmjpro - you could also use a ref.

@jmjpro
Copy link
Author

jmjpro commented Jan 19, 2016

with normal events the name is a field in the event.target object. not the case here since the event.target is a div instead of the backing hidden input element.

@alitaheri
Copy link
Member

Closing in favor of #3096.

@oliviertassinari oliviertassinari added the component: select This is the name of the generic UI component, not the React module! label Aug 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: select This is the name of the generic UI component, not the React module! docs Improvements or additions to the documentation
Projects
None yet
Development

No branches or pull requests

4 participants