I am trying to change the style options for my react-select component (specifically trying to get rid of the border and change the font and text color) but am not sure how to fix the TypeScript errors. I have the following code:
import React, {useState} from 'react';
import Select, { ValueType } from 'react-select';
type OptionType = {
value: string;
label: string;
};
const LanguageSelector = () => {
const languageOptions: OptionType[] = [
{ value: 'English', label: 'EN' },
{ value: 'German', label: 'DE' },
{ value: 'French', label: 'FR' },
];
const [selectedOption, setSelectedOption] = useState<ValueType<OptionType, false>>(languageOptions[0]);
const handleChange = (option: ValueType<OptionType, false>) => setSelectedOption(option);
const customStyles = value => ({
control: (provided, state) => ({
...provided,
alignItems: "baseline",
backgroundColor: value ? "gray" : "white"
})
});
return (
<div>
<Select
value={selectedOption}
onChange={handleChange}
options={languageOptions}
styles={customStyles}
/>
</div>
)
};
export default LanguageSelector;
The errors are that provided, state, and value all implicitly have an 'any' type.
I'm assuming provided would have type CSSProperties, but am unsure about state. Does anyone know what these types should be?