instea / react-native-color-picker

Color picker component for IOS/Android
Apache License 2.0
272 stars 67 forks source link

sliderComponent #27

Closed cristea2017 closed 4 years ago

cristea2017 commented 4 years ago

I have error when i try to add sliderComponent

My code :

<ColorPicker onColorSelected={color => alert(Color selected: ${color})} style={{ flex: 1 }} color={this.state.color} onColorChange={this.onColorChange} sliderComponent={<Slider style={{ width: 200, height: 40 }} minimumValue={0} maximumValue={10} minimumTrackTintColor="#FFFFFF" maximumTrackTintColor="#000000" />} />

I get this error :

element type is invalid expected a string (for built-in components) or a class/function but got objec.

According code of https://github.com/instea/react-native-color-picker/blob/master/src/HoloColorPicker.js , sliderComponent is of type 'PropTypes.elementType' where PropType is a npm library https://www.npmjs.com/package/prop-types

So on prop-types library documentation is indicated that

// A React element type (ie. MyComponent). optionalElementType: PropTypes.elementType, So i am doing wrong , please help

sodik82 commented 4 years ago

the problem is that you try to pass ReactElement instead of ReactCompoment....

define your own slider component somewhere else like this

const MySlider = (props) => <Slider .... />

and then use it sliderComponent={MySlider}

cristea2017 commented 4 years ago

problem is that you try to pass ReactElement instead of ReactCompoment....

define your own slider component somewhere else l

Thanks a lot ;)