how to optimise component that useContext in React

the question is simple but it probably has some answers that I’m still not aware of

How to optimise component, that use useContext ? Obviously this component will be rerendered every time context value changed(correct me if i’m wrong) and the same works for redux either(again correct me). I’m trying to crack this question to avoid pitfalls at interview.

I asked chat GPT and it answered me the following

import React, { useContext, memo } from 'react';

const MyComponent = memo(() => {
  const contextValue = useContext(MyContext);

});

But as far as I understand – that is not correct and won’t affect rerendering.

What I think is that we can wrap in react memo components that are children of that component that use useContext, and when we use useContext we should be aware of the price we pay to use global state, that it will cause some redundant rerenders and we can just optimize children on such components to prevent rerender (if we need it);