reactjstypescriptreact-color

Cannot use react-color Saturation with @types/react-color


I am trying to create a custom color picker using react-color library (^2.19.3) with @types/react-color (^3.0.4). As Saturation component is not exported from types index file the only way to how to import it is react-color/lib/components/common. Using Saturation like (this):

<Saturation color={props.color} onChange={onChange} />

Will trigger an error Uncaught TypeError: Cannot read property 'h' of undefined (Types are not the same as original Saturation from react-color library).

I created minimal example (just uncomment Saturation section). Any Ideas on how to use Saturation component?


Solution

  • I found out what latest versions of both libraries are not compatible. After installation of @types/react-color@2.17.5 problem disappeared with the usage of:

    <Saturation hsl={props.hsl} hsv={props.hsv} ... />