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

150
Views
type for useState with callback - Type has no call signatures

I am using useState with a callback:

interface Props {
  label: string;
  key: string;
}

const [state, setState] = useState<Props[]>([]);


setState((prev : Props[]) => [...prev, newThing])

I get the error:

2349: This expression is not callable. Type 'Props' has no call signatures.

I'm not sure how to define a call signature inside the Props interface/type, what is the best approach to resolve this?

Edit:

This is how I am using it inside my code:

Interface:

interface TagProps {
  left: string;
  top: string;
  backgroundColor: string;
  rotation: number;
  label: string;
  key: string;
}

Home.tsx

const Home: FC<TagProps> = (setState, state: TagProps[]) => {
  const createTag = (e: any) => {
    const tagSpec = {
      left: e.clientX + "px",
      top: e.clientY + "px",
      backgroundColor: randomColour(colors),
      rotation: randomNumber(-20, 20),
      label: tech[randomNumber(0, tech.length - 1)],
      key() {
        return this.label + this.backgroundColor;
      },
      position: "absolute",
    };
    setState((prev: TagProps[]) => [...prev, tagSpec]);
  };

...

}

App.tsx

function App() {
  const [tag, setTag] = useState<TagProps[]>([]);

  return (
    <BrowserRouter>
      <Routes>
        <Route path="/" element={<Layout />}>
          <Route index element={<Home setState={setTag} state={tag} />} />
          <Route path="/blog" element={<Blog />} />
        </Route>
      </Routes>
    </BrowserRouter>
  );
}
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

You have to desctucture your props

// from
const Home: FC<TagProps> = (setState, state: TagProps[]) => {

// to
const Home: FC<TagProps> = ({ setState, state }) => {

Also I wouldn't pass setState down to the component

about 4 years ago · Juan Pablo Isaza Report

0

React Functional Component's property are under the first param, you can do this to get them

const Home = (props) => {
  const { state, setState } = props;

  // setState(...)
}
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!