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

How can type a button including an icon with React Native?

$
0
0

I'm trying to type a button component where all of them have to get a title, but some don't get an icon.This icon comes from "@expo/vector-icons". What should I do when I put the component display an icon too?

Like: <Button icon={<FontAwesome name="icon-name" size={24} colo="color"} title="Title here" />

My actual code:

type IButtonProps = TouchableOpacityProps & {    title: string;    icon?: any;}function Button({ title, icon }: IButtonProps) {    return(<Container><Text>                {title}</Text></Container>    );}export default Button;

and here is when the component is used for display

<Button                     title="Login with Github"                     icon={`${<FontAwesome name="github" size={24} color="#FFFFFF" />                    }`}                 />

Viewing all articles
Browse latest Browse all 6287

Trending Articles



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