Honestly this is just more of why I think React is ignorant incompetent trash that just makes everything harder, and why I view typescript as a horrifyingly bad attempt at turning JavaScript into something it's not.
Hence why when I go into client sites who are being sued for accessibility violations, typescript, react, vue, front-end frameworks, and the like are the first blasted things I have to rip out part and parcel.
Just like the code you posted that I'd sooner suck the business end of a shotgun than deploy "real world".
Amazing how by avoiding all this junk I end up writing 1/10th the code, with clearer code, that has higher client side compatibility and graceful degradation.