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

fix: Slider onChange function type problem #2127

Closed
1 task done
maximegheraille opened this issue Jan 24, 2021 · 0 comments · Fixed by #2137
Closed
1 task done

fix: Slider onChange function type problem #2127

maximegheraille opened this issue Jan 24, 2021 · 0 comments · Fixed by #2137
Assignees
Labels
1 coin bug Something isn't working

Comments

@maximegheraille
Copy link

  • I have searched the issues of this repository and believe that this is not a duplicate.

Describe the bug

when using the slider an settting the state from the onChange event, I get a problem.

The type is supposed to be : (event: ChangeEvent<HTMLElement>) => void but the problem with that is that I cannot access the event.target.value Property 'value' does not exist on type 'EventTarget & HTMLElement'..

Using event: React.ChangeEvent I can access the event.target.value but not I cannot compile it, it gives this type error Type '(event: React.ChangeEvent<HTMLInputElement>) => void' is not assignable to type '(event: ChangeEvent<HTMLElement>) => void'.

Do you guys need to update the type or is there an another way to get the value ?

My code:

import { useEffect, useState } from "react"


const Navigation: React.FC = () => {
    const [Volume, setVolume] = useState<number>(100)

    return (
        <>
                    <div className="flex items-center justify-center pr-1">
                   <Slider className='text-black p-1' value={Volume} onChange={(event: React.ChangeEvent<HTMLInputElement>) => setVolume(parseInt(event.target.value))} max='100' min='0' />
        </>
    )
}

export default Navigation
@maximegheraille maximegheraille added the bug Something isn't working label Jan 24, 2021
HellWolf93 added a commit that referenced this issue Jan 28, 2021
LeandroTorresSicilia pushed a commit that referenced this issue Jan 30, 2021
* fix: fix event callback parameter type

fix: #2127

* fix: update types on input events

Co-authored-by: Tahimi <[email protected]>
jpetaux pushed a commit to jpetaux/react-rainbow that referenced this issue Jun 27, 2021
* fix: fix event callback parameter type

fix: nexxtway#2127

* fix: update types on input events

Co-authored-by: Tahimi <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1 coin bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants