I think in this case a function that returns a function would be a bit cleaner?
Ted Chen
111

Your createAlertBox method creates a new function reference every time it is called. That means every time the parent renders, the child receives a new function reference as a prop. The child therefore rerenders even though the function did not change. It is the same problem.

Like what you read? Give Charles Stover a round of applause.

From a quick cheer to a standing ovation, clap to show how much you enjoyed this story.