TypeScript error: 'CSSObjectWithLabel' is not assignable to type 'CSSProperties | undefined' (react-select v5.8.0 vs @types/react v18.3.3) #5952
Labels
issue/bug-unconfirmed
Issues that describe a bug that hasn't been confirmed by a maintainer yet
I'm following the docs regarding overriding the different components of a select, and I'm getting an error when passing
getStyles(...)
into the returneddiv
element by doing smth like<div ... style={getStyles("menuList", props)}>
(see the sandbox)The error is as follows:
Looks like React's builtin CSSProperties don't like array values (
string[] | AccentColor[]
), which makes sense given thatReact.CSSProperties
are based off the non-fallback variant ofcsstype.Properties
in@types/react:18.3.3
:And react-select imports
CSSObject
from@emotion/react
which does allow fallback values:I quick workaround would probably be to do something like
<div ... style={getStyles("menuList", props) as React.CSSProperties}>
, but I'm not sure if putting type assertions everywhere is going to cause issues down the road.The text was updated successfully, but these errors were encountered: