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

Typescript useState error boolean has no call signatures

$
0
0

I am using Typescript with React Native and I am having trouble with an error on the console. It says "This expression is not callable. Type 'Boolean' has no call signatures."The code is simple, it just has two cards in the home page and if the user clicks one of them, it should send the user to that page. I tried to achieve that trough useState in order to understand better the hook. This is the code in home.tsx:

import { Button, StyleSheet, Text, View } from "react-native"import CardsComponent from "../../components/cards/cards"import EcoNoticias from "../../components/EcoNoticias/EcoNoticias";import React from "react";import { useState } from "react";export interface HomeComponentProps {}const HomeComponent: React.FC<HomeComponentProps> = () => {    const [buttonPressed, setButtonPressed] = useState<boolean>(false);    const handlePage = () => {        setButtonPressed(true);    };    return (<><View><Text style={styles.title}>Hello User</Text><View>                    {() => buttonPressed(false)} ?<CardsComponent><Text style={styles.textCard}>Tips</Text><Button title='Tips' onPress={() => {}} /></CardsComponent><CardsComponent><Text style={styles.textCard}>Eco-Noticias</Text><Button title='Eco-Noticias' onPress={handlePage} /></CardsComponent> : <EcoNoticias /></View></View></>    );};const styles = StyleSheet.create({    title: {        fontSize: 23,        paddingBottom: 50,        textAlign: 'center',    },    textCard: {        color: 'white',        fontWeight: '700',        textAlign: 'center',        paddingBottom: 10,    },    buttonStyle: {        width: '50%',    },});export default HomeComponent;

The error it's in the if ternario, line 24: "buttonPressed(false)".


Viewing all articles
Browse latest Browse all 6287

Trending Articles



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