Property 'opacity' does not exist on type 'IntrinsicAttributes' throwing and error for view Opacity in React native

Viewed 465

After writing this sentence, typescript file shows an error on below line.

React-Native 0.60+ There is a new opacity prop that you can pass in:

<View opacity={true ? 0.5 : 1}> </View>

Error stack: error property 'opacity' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes view opacity.

No overload matches this call. Overload 1 of 2, '(props: ViewProps | Readonly): View', gave the following error. Type '{ children: Element; opacity: boolean; }' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes & Readonly & Readonly<{ children?: ReactNode; }>'.

Property 'opacity' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes & Readonly & Readonly<{ children?: ReactNode; }>'.

Overload 2 of 2, '(props: ViewProps, context: any): View', gave the following error. Type '{ children: Element; opacity: boolean; }' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes & Readonly & Readonly<{ children?: ReactNode; }>'.

How to resolve this warning, thanks in advance.

1 Answers

I resolved this error by followin code :

<View style={{ opacity: true  ? 0.5 : 1 }}>

Happy Coding !

Related