1

I'm trying to use onChange function on a slider, but I keep getting and error with the Value. Am I doing something wrong ?

I'm using TypeScript and ViteJS.

Value error

My code:

      <Slider
        color="success"
        aria-label="Small steps"
        defaultValue={0.00000005}
        step={1}
        marks
        min={5}
        max={20}
        valueLabelDisplay="auto"
        value={passwordLength}
        onChange={(e) => setPasswordLength(e.target.value)}
      />
bguiz
  • 27,371
  • 47
  • 154
  • 243

1 Answers1

1

Looking at the error reported: Property 'value' does not exist on type 'EventTarget'

Since you are using a custom component <Slider>, you need to explicitly tell TypeScript the type of the HTMLElement which is your target.

Look at this for more details

Sandro Maglione
  • 306
  • 1
  • 5
  • 8