Material-ui: How to get value of slider in onChange handler?

Created on 19 Jan 2016  路  9Comments  路  Source: mui-org/material-ui

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?

Select docs

Most helpful comment

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

All 9 comments

@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?

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

yes got it now. thanks!

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

I have to pass that the name as yet another param

Indeed, why is this bad?

@jmjpro - you could also use a ref.

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.

Closing in favor of #3096.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

finaiized picture finaiized  路  3Comments

revskill10 picture revskill10  路  3Comments

newoga picture newoga  路  3Comments

FranBran picture FranBran  路  3Comments

reflog picture reflog  路  3Comments