Aditya Loshali
1 min readMar 24, 2019

--

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

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