Answer the question
In order to leave comments, you need to log in
Why isn't the second argument being called inside React.memo()?
I was expecting that after the component is clicked, the check function inside React.memo() will be executed and it will not update. But this function is not executed, and I can't figure out what's wrong.
const Item = styled.div`
//styles
`;
const Cell = (props) => {
const [isSelected, setIsSelected] = useState(false);
return (
<Item onClick={() => setIsSelected(!isSelected)} status={{key: isSelected}} />
)
}
const check = (prevProps, props) => prevProps === props;
const memoComp = React.memo(Cell, check)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question