Lets say i have a child component that just return a div element
Child Component :
function Child() {
return <div className={styles.alertBox}>No Data Found</div>;
}
it will always re-render when the parent state change, so to prevent it re-render we will wrap it using React.memo
example :
export default function Parent(){
*some state and setState stuff*
const MemorizeChild = React.memo(Child)
return MemorizeChild
By doing that we prevent our Child Component to re-render everytime we change the state
My Question is: did we really need to memorize the Child Component although it just return few line of html and does not execute some heavy function, because we all know that Memorizaition are not Free. in return of Time we trade space (Memory / Cache). if it not can you tell me when should i memorize my component