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

143
Views
React dev tools highlighting components that doesn't update

I'm testing the use-context-selector lib to prevent unnecessary rendering in react ContextApi. I create this simple application:

export const HomeProvider = (props: PropsWithChildren<{}>) => {
  const [x, setX] = React.useState(0);

  const [y, setY] = React.useState(0);

  return (
    <HomeContext.Provider value={{ x, setX, y, setY }}>
      {props.children}
    </HomeContext.Provider>
  );
};

export const HomeModule = () => {
  return (
    <HomeProvider>
      <CounterScreen></CounterScreen>
      <br />
      <br />
      <MessageScreen></MessageScreen>
    </HomeProvider>
  );
};

The child components are:


export const MessageScreen = () => {
  const x = useContextSelector(HomeContext, (context) => context.x);

  const setX = useContextSelector(HomeContext, (context) => context.setX);

  return (
    <>
      <h1>Teste X</h1>
      {x} <button onClick={() => setX(x + 1)}>X</button>
    </>
  );
};

export const MessageScreen = () => {
  const x = useContextSelector(HomeContext, (context) => context.x);

  const setX = useContextSelector(HomeContext, (context) => context.setX);

  return (
    <>
      <h1>Teste Y</h1>
      {y} <button onClick={() => setY(y + 1)}>X</button>
    </>
  );
};

The result, when I click in any one of those button is that indeed the child components doesn't rerender:

https://i.stack.imgur.com/9adCh.png

But, when I use the option: Highlight updates when components render in settings, all components on the screen is highlighted.

So, am i missing something or i'm right about the child components not rerendering ?? I saw other videos on youtube that show that when using this lib, the component that didn't render was not highlighted.

about 4 years ago · Juan Pablo Isaza
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!