It might be just me, but this is how frontend libraries should have been structured in the first place unlike relying on callbacks / state change hooks.

Linearly written code is much easier to understand and scan.