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

Property 'hex' does not exist on type 'ColorValue'. #6

Open
egazarian opened this issue Apr 14, 2022 · 2 comments
Open

Property 'hex' does not exist on type 'ColorValue'. #6

egazarian opened this issue Apr 14, 2022 · 2 comments

Comments

@egazarian
Copy link

egazarian commented Apr 14, 2022

Version

typescript: 4.1.2
mui-color: 2.0.0-beta.2
@mui/material: 5.0.4
react: 17.0.2
@emotion/react: 11.5.0
@emotion/styled: 11.3.0

Issue

When trying to access to the hex value of a ColorValue inside of ColorPicker onChange event handler, typescript throw Property 'hex' does not exist on type 'ColorValue'.
Same issue for all the properties of ColorValue object.

Screenshot

Capture d’écran 2022-04-14 à 10 16 19

Workaround

<ColorPicker
    onChange={(e) => {
        const color = e as ColorObject;
        console.log(color.hex);
    }}
/>

Should the onChange handler argument type be ColorObject instead of ColorValue ?

@Briimbo
Copy link

Briimbo commented Apr 29, 2022

I don't think this is a bug. You can also enter text in the color picker to get a color. The argument type used to be Color though instead of ColorValue
grafik

@egazarian
Copy link
Author

egazarian commented May 6, 2022

Ok, I got it. And yes, it would be better to have an argument of type Color, instead of ColorValue. In this way we should be able to get the color as any format.

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

2 participants