This is a basic hook + Component wrapper for showing when components update due to renders or state updates.
This is primarily useful as a demonstration of how tools like React.memo()
affect component rendering. Additionally, it shows how you might not need memoization and that reorganizing your application can improve application performance. Specifically, localizing your applications state with the components that depend on it can help minimize the scope of a rerender.
ControlledCounter
's state is controlled via the parent. Execution its action results in not only it updating, but its siblings and their children updating as well.Counter
's state is controlled internally, meaning its action only triggers a rerender of itself.