Aditya Loshali
Mar 24 · 1 min read

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.

Aditya Loshali

Written by

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