Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

142
Views
props.setActiveTab is not a function hooks

I am passing state hooks as props to my components and my HeaderButton works perfectly fine but when I try implementing onPress I get an error saying "props.setActiveTab is not a function"

import React from "react";
import { useState } from "react";
import { View, Text, TouchableOpacity } from "react-native";

export default function Header(props) {
  const [activeTab, setActiveTab] = useState("Delivery");
  return (
    <View style={{ flexDirection: "row", alignSelf: "center"}}>
      <HeaderButton
        text="Delivery"
        bgColor="black"
        textColor="white"
        activeTab={activeTab}
        setActiveTab={activeTab}
      />
      <HeaderButton
        text="Pick up"
        bgColor="white"
        textColor="black"
        activeTab={activeTab}
        setActiveTab={activeTab}
      />
    </View>
  );
}

const HeaderButton = (props) => (
  
  <TouchableOpacity
    style={{
      backgroundColor: props.activeTab === props.text ? "black" : "white",
      paddingVertical: 10,
      paddingHorizontal: 40,
      borderRadius: 10,
    }}

    onPress={() => props.setActiveTab(props.text)}
  >
    <Text style={{ color: props.textColor }}>  {props.text}</Text>
  </TouchableOpacity>
);
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Because you are not passing the function here:

setActiveTab={activeTab}

change to:

setActiveTab={setActiveTab}
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!