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

Typescript erorr while using 'react-native' button with additional props

$
0
0

I am new to Typescript and was trying to add it in my react-native project, so after integrating it, i am stuck at the type error for Button .

Here is the code for below

import React from "react";import { Button, Image, StyleSheet, Text, View } from "react-native";interface Props {  navigation: NavigationScreenProp<any, any>;}export const Landing: React.FC<Props> = ({}) => {  return (<View style={styles.container}><Button onPress={() => {}} title="button" style={styles.button} /></View>  );};const styles = StyleSheet.create({  button: {},});

So the Button gives error

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

I also tried extending the prop like

interface ButtonPropsNew extends ButtonProps {  style: any;}type IProps = Props & ButtonPropsNew;

and then passing IProps to this component

export const Landing: React.FC<IProps> = (props) => {}

but i still get type error on using "style" prop on the button


Viewing all articles
Browse latest Browse all 6287

Trending Articles



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