Sign in

How can we get rid of the unnecessary renders on Child components when we pass in a function as a prop?

Photo by British Library on Unsplash
const Parent = ()=> {
const [someVal, setSomeVal] = useState(null);
const eventHandler = ()=> {
handleTheOnClick(someVal);
}
return <Child onClick={eventHandler}/>
}



The beginning


Asim KT

Front end engineer Quintype Inc.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store