Struggling with updating the style property in React Native using TypeScript. When trying to update it from the state, an error is encountered.
const [VerifiedCheck, setIsVerifiedCheck] = useState("flex");
<View style={{display: VerifiedCheck}}>
<Icon name={'check-circle'} size={24} color={'green'} />
</View>
The error occurs at style
:
No overload matches this call.
Overload 1 of 2, '(props: ViewProps | Readonly<ViewProps>): View', gave the following error.
Type '{ display: string; }' is not assignable to type 'StyleProp<ViewStyle>'.
Types of property 'display' are incompatible.
Type 'string' is not assignable to type '"none" | "flex" | undefined'.
Overload 2 of 2, '(props: ViewProps, context: any): View', gave the following error.
Type '{ display: string; }' is not assignable to type 'StyleProp<ViewStyle>'.
Types of property 'display' are incompatible.
Type 'string' is not assignable to type '"none" | "flex" | undefined'.ts(2769)
index.d.ts(2522, 5): The expected type comes from property 'style' which is declared here on type 'IntrinsicAttributes & IntrinsicClassAttributes<View> & Readonly<ViewProps> & Readonly<{ children?: ReactNode; }>’
index.d.ts(2522, 5): The expected type comes from property 'style' which is declared here on type 'IntrinsicAttributes & IntrinsicClassAttributes<View> & Readonly<ViewProps> & Readonly<{ children?: ReactNode; }>’