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

No overload matches this call Typescript on Button in React native

$
0
0

I have my Welcome.tsx file:

import React from 'react';import {View, StyleSheet, Text, Button, TouchableOpacity} from 'react-native';import Icon from 'react-native-vector-icons/Feather';const WelcomeScreen: React.FC<{}> = () => {  return (<View style={styles.container}><View style={styles.logo}><Icon size={150} color="black" name="book-open" /><Text style={styles.logoText}>Book Worm</Text></View><View style={styles.divider}><TouchableOpacity><Button title="Login" color="black" style={styles.btn} /></TouchableOpacity><TouchableOpacity><Button title="Sign-up" color="black" style={styles.btn} /></TouchableOpacity></View></View>  );};const styles = StyleSheet.create({  container: {    flex: 1,  },  logo: {    flex: 1,    borderWidth: 1,    alignItems: 'center',    justifyContent: 'center',  },  logoText: {    fontSize: 50,    fontWeight: '100',  },  divider: {    flex: 1,    borderWidth: 1,  },  btn: {    borderWidth: 1,    borderColor: 'black',    backgroundColor: 'black',  },});export default WelcomeScreen;

As you can see it pretty normal. However, Visual Studio code is highlighting style property and is throwing the following error:

No overload matches this call.  Overload 1 of 2, '(props: ButtonProps | Readonly<ButtonProps>): Button', gave the following error.    Type '{ title: string; color: string; style: { borderWidth: number; borderColor: string; backgroundColor: string; }; }' is not assignable to type 'IntrinsicAttributes & 

Here's the image:

enter image description here

Any idea what's causing this overload matches call? been wondering for a couple times this happened.


Viewing all articles
Browse latest Browse all 6287

Trending Articles



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