Failed prop type: Invalid prop `progressBar` supplied to `Rheostat`
jchapelle opened this issue · comments
I get this warning messages in console when using rheostat
Warning: Failed prop type: Invalid prop progressBar
supplied to Rheostat
.
Warning: Failed prop type: Invalid prop progressBar
supplied to withStyles(Rheostat)
.
Can somebody explain me why I receive this warnings ?
I'm using a custom progressBar element and I had to use register a custom theme in order to have rheostat and react-calendar to work together
ThemedStyleSheet.registerTheme({
rheostat: {
...RheostatDefaultTheme.rheostat,
color: {
...RheostatDefaultTheme.rheostat.color,
progressBar: 'red',
},
},
reactDates: {
...ReactDatesDefaultTheme.reactDates,
},
});
What are you passing as the progressBar prop?
I'm using styled-components. I have the same error for the handle by the way.
import styled from 'styled-components';
const ProgressBar = styled.div`
background-color: #008489 !important;
position: absolute !important;
width: 100% !important;
border-radius: 4px !important;
height: 4px !important;
top: 0px !important;
}
Here is the Rheostat definition
<Rheostat
handle={SliderHandle}
progressBar={ProgressBar}
onValuesUpdated={this.onValuesUpdated}
values={[this.state.age]}
min={0}
max={18}
/>
https://github.com/airbnb/rheostat/blob/master/src/Slider.jsx#L23 requires it to be a function or a string - ie, a component, not an element. I’m not familiar with styled-components, what is ProgressBar there?
Thanks a lot, by defining my component like below, I have no more warnings.
const SliderHandleStyledComponent = styled.div`
left: 0%;
margin-left: -15px;
position: absolute;
width: 32px !important;
height: 32px !important;
border-width: 1px !important;
border-style: solid !important;
border-color: #008489 !important;
background-color: #ffffff !important;
border-radius: 32px !important;
outline: none !important;
z-index: 2 !important;
box-shadow: 0 2px 2px rgba(72, 72, 72, 0.3) !important;
top: -15px !important;
&:hover{
cursor: pointer;
}
}
`;
const SliderHandle = ({ className, children }) => (
<SliderHandleStyledComponent className={className}>
{children}
</SliderHandleStyledComponent>
);
Your handle isn’t using all the props it’s getting.
I’d recommend starting with the default handle, get everything working, and worry about styling it later.