Just a note, this pattern will bite you in Server Side Rendering, as the `useEffect` is not run there, the rendered markup wont contain data from the children. Calling `setState` of parent without `useEffect` will probably work, but React prints red warning that you should not do it for a good reasons. Long story short, there is currently no way to pass data from children to the parent, that will work during Server Side Rendering.

Vaclav Novotny

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