the unnecessary rerender does not happens when you use it like this :

<ChildComponent callback={this.someMethod}>

here you are just giving a reference.

Instead it happens when you use it like this:

<ChildComponent callback={() => this.setState({ clicked: true }) }>

in this case you are essentially passing a brand new anonymous function prop to child on every rerender of parent. since it isn’t stored anywhere. hence.

I’m a full stack web developer working with Javascript on React and Node.js everyday.

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