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