Quantcast
Channel: Active questions tagged react-native+typescript - Stack Overflow
Viewing all articles
Browse latest Browse all 6287

'Unnecessary' TS error upon providing a prop to a native ios component

$
0
0

I created a native module using Swift called CounterView, and when I use it as such:

<CounterView style={{flex: 1}} />

I get this nasty warning! But the thing is, everything works. The error goes away if I remove the style prop, but nothing would render without the {flex: 1}. So I tried to wrap this inside a View, but then it renders relative to the entire screen rather than the wrapper. How can I get rid of this error? Am I doing something wrong to make my component "read-only"?

Type '{ style: { flex: number; }; }' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes<Component<unknown, {}, any> & Readonly<NativeMethods>> & Readonly<...> & Readonly<...>'.  Property 'style' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes<Component<unknown, {}, any> & Readonly<NativeMethods>> & Readonly<...> & Readonly<...>'.

I can circumvent the issue if I do this:

<View style={{flex: 1}}><View style={{flex: 1}} /><View style={{flex: 1}}><CounterView /></View></View>

This takes care of the other half of the screen that will be occupied by another flex:1 container, but this looks pretty silly.


Viewing all articles
Browse latest Browse all 6287

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>