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

126
Views
Do state setters get recreated when the component re-render?

A function defined in some component, gets recreated on every render, if it's not memoized with some useCallback, that's what I've learned. Does this apply to state setters, like setState in below component?

To my knowledge, foo in below component is typically a function that gets recreated on every re-render.

import { useState } from "react";

export default function App() {
  const [state, setState] = useState(true);
  const foo = () => console.log("Hello Word");
  return (
    <div>
      <button onClick={() => setState(!state)}>Change state</button>
    </div>
  );
}
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

No, the dispatch function is guaranteed to always stay the same hence why you don't need to place it in the dependency array. "React guarantees that setState function identity is stable and won’t change on re-renders." React docs

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!