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

No overload matches this call error in React Native [duplicate]

$
0
0

Issue

The following code throws an error. The code is a minimal executable code to reproduce the error of the original one.

import React from 'react';import { Button, StyleSheet } from 'react-native';const MyButton = () => {  return (<Button      title="Click me"      style={styles.button}    />  );};const styles = StyleSheet.create({  button: {    backgroundColor: '#0f0',    color: '#fff',    padding: 10,  },});

The error:

No overload matches this call.  Overload 1 of 2, '(props: ButtonProps): Button', gave the following error.    Type '{ title: string; style: { backgroundColor: string; color: string; padding: number; }; }' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes<Button> & Readonly<ButtonProps>'.      Property 'style' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes<Button> & Readonly<ButtonProps>'.  Overload 2 of 2, '(props: ButtonProps, context: any): Button', gave the following error.    Type '{ title: string; style: { backgroundColor: string; color: string; padding: number; }; }' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes<Button> & Readonly<ButtonProps>'.      Property 'style' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes<Button> & Readonly<ButtonProps>'.ts(2769)

As a result, the react native webpage is empty.

Environment

  • Windows 11
  • npm 10.8.2

What I did so far

I checked the following pages in vain.

What should I do to solve this?


Viewing all articles
Browse latest Browse all 6581

Latest Images

Trending Articles



Latest Images