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

Why do TypeScript tell me that a property doesn't exist on Button Component from NativeBase but still renders it?

$
0
0

I'm using NativeBase on a React Native project and while everything works just fine when I run the app on my iPhone using Xcode, TypeScript tell me that the property "onPress" does not exist on the type of the NativeBase Button.

To simplify things here is my code :

import { Button } from 'native-base';...<Button  variant="ghost"  colorScheme="blueGray"  onPress={() => {  console.log('Ok')  }}>

And the error I get :

Type '{ children: string; onPress: () => void; }' is not assignable to type 'IntrinsicAttributes & IButtonProps & { ref?: MutableRefObject | undefined; }'.Property 'onPress' does not exist on type 'IntrinsicAttributes & IButtonProps & { ref?: MutableRefObject | undefined; }'.ts(2322)

Again, the code works just fine but it's annoying to get one error per button in each file of my project.

I'm not really used to React Native nor NativeBase so I can't find why it throws this error.

I tried to look a bit into the files to see if I could find the "onPress" property somewhere since it's working and it's on the documentation and I found out that according to TS :

import type { PressableProps } from 'react-native';

Module '"react-native"' has no exported member 'PressableProps'.ts(2305)

My question is why TS tell me that onPress doesn't exist but I figured it could help somehow since it looks like that's where onPress is supposed to be.


Viewing all articles
Browse latest Browse all 6287

Trending Articles



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