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

TypeError (TS2740) sliderComponent #41

Open
Hektar90 opened this issue Feb 22, 2021 · 4 comments
Open

TypeError (TS2740) sliderComponent #41

Hektar90 opened this issue Feb 22, 2021 · 4 comments

Comments

@Hektar90
Copy link

I just want to use the default slider from '@react-native-community/slider'

Bildschirmfoto 2021-02-22 um 17 56 39

adding this to the 'sliderComponent' prop results in an type error

Bildschirmfoto 2021-02-22 um 17 48 45

Slider is an intersection type of React.Component

Bildschirmfoto 2021-02-22 um 17 59 52

@Frakette
Copy link

Frakette commented Mar 3, 2021

I have an issue too using '@react-native-community/slider' as sliderComponent. I don't get a crash but i think there is indeed an issue with the typechecking of sliderComponent props.
Here's an extract of my code :
<ColorPicker
style={{ flex: 1 }}
defaultColor={newColor}
onColorChange={color => setNewColor(fromHsv(color))}
// not working for now - seems to be an error in code of the package - see latest issue in package
sliderComponent={(props: any) => (
<SliderComponent
value={props.value}
onValueCange={() => props.onValueChange()}
/>
)}
/>

My SliderComponent get the value prop.
However, the onValueChange prop doesn't seem to work because when I slide, none of the "v" / "s" value are changing.

@Hektar90
Copy link
Author

Hektar90 commented Mar 3, 2021

@Frakette Do you use typescript in your project?
This is just a type error issue which means it compiles and works. Only my IDE is complaining.

SliderComponent isn't customized, is it? So just add the component class like so:

<ColorPicker ...sliderComponent={SliderComponent }

this should work if i get you right

@Frakette
Copy link

Frakette commented Mar 4, 2021

@Hektar90 Yes I use typescript on my project. Actually my issue might not be fully related to yours but I also see a Typescript error when I try to add a sliderComponent.

I was struggling to pass props to my SliderComponent because I was passing it directly as a component and it was not working but as a function that returns a component it works although the slider is a bit glitchy.

However, as you noticed, I still get get the same Typescript error than you when passing SliderComponent.
I ended up using a //@ts-expect-error to avoid compilation errors. But a correction on the type checking would be great :)

@gprinc-hu
Copy link

Any update in this issue? I have the same problem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants