zillow / react-slider

Accessible, CSS agnostic, slider component for React.
https://zillow.github.io/react-slider
MIT License
883 stars 231 forks source link

TypeScript error when using Augmented CSS in React v18 #285

Open user1990 opened 1 year ago

user1990 commented 1 year ago

Description

In a Next.js project, we have the following minimal component:

import ReactSlider from "react-slider"

<ReactSlider
  renderThumb={(thumbProps) => <div {...thumbProps} />}
  renderTrack={(trackProps) => <span {...trackProps} />}
/>

We have augmented CSS variable type react.d.ts:

import 'react';

declare module 'react' {
  interface CSSProperties {
    [key: `--${string}`]: string | number | undefined;
  }
}

Error

Index signature for type '--${string}' is missing in type 'Properties<string | number, string & {}>'.ts(2322)

image

The issue may have arisen due to a mismatch in React versions, as the react-slider seems to have used React v17.0.2 as founded in the .lock file, while this issue was not present in React v17?

Environenment

Library Version
React.js 18.2.0
Next.js 13.1.6
React-Slider 2.0.4
@types/react-slider 1.3.1
bertPB commented 1 year ago

Having the same issue here, did you manage to fix this?

Any update on this?

user1990 commented 1 year ago

Having the same issue here, did you manage to fix this?

Any update on this?

No any updates/response, still having this issue. Currently using this workaround:

<div {...thumbProps} {...preventSwipingHandlers} style={{ ...thumbProps.style }} />