Redux-form-material-ui: Warning: Failed prop type: Invalid prop `value` of type `string` supplied to `Slider`, expected `number`.

Created on 30 Nov 2016  路  1Comment  路  Source: erikras/redux-form-material-ui

I'm receiving the above error when using the slider component. I've used the component as follows:

<Field name='cycleValue' value={0} min={0} max={5000} step={10} component={ Slider } defaultValue={2500} />

When I check the initial value of the value prop initially after render, it's an empty string (""), which triggers the error. The defaultValue prop is ignored.

There are two other text fields that share the same name (and the same value). Despite the error the slider works normally and the values update on these components. I've also disconnected the slider from these other text fields, but the error persists.

Any suggestions? I feel though I may have missed an important step, but so far the other components in my forms have been working absolutely fine.

Most helpful comment

I've personally solved it in a similar way to how the DatePicker issue was solved:

<Field name='cycleValue' format={(value, name) => value === '' ? 0 : value} component={ Slider }/>

>All comments

I've personally solved it in a similar way to how the DatePicker issue was solved:

<Field name='cycleValue' format={(value, name) => value === '' ? 0 : value} component={ Slider }/>

Was this page helpful?
0 / 5 - 0 ratings