Answer the question
In order to leave comments, you need to log in
Where and why does Create React App convert hsl to rgb?
Recently I came across the fact that the colors in hsl in inline styles are converted to rgb when using the create-react-app build.
Example
:
https://codesandbox.io/s/agitated-fermat-7vts7
:
https://codepen.io/zarza666/pen/OJPyaRO
At the same time, I caught such a bug that it tried to convert at compile time, but I needed a color calculation at runtime. But it didn't work in the sandbox.
Does anyone have any idea where this conversion came from and why is it needed?
I haven't been able to find an answer to this question either on Google or on Github.
Answer the question
In order to leave comments, you need to log in
this is not done by CRA or React, but by the browser, in the example on codepen you are using an ancient version of React, that's why the results are different.
try
to be honest, I don’t see any problem in this, because you work with the hsl value inside the react, so what’s the difference what it converts into the output.
the problem can arise only if you read the attribute directly from the DOM element, and you need hsl, but in that case you are doing something wrong.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question