DEV Community

[Comment from a deleted post]
Collapse
 
rleija_ profile image
Ruben • Edited

Great question.

Overall it’s more inline with the rest of your react code.

1 problem with getElementById is that you can have multiples of the same ID. So if you have an input component with an ID of β€œfoo”, then that will display on the output multiple times.

Great example here.

Another advantage is that you can toss the reference to another component, which helps maintain your unidirectional data flow.

Collapse
 
dance2die profile image
Sung M. Kim

I can clearly see why now πŸ™‚.
Thank you, Ruben πŸ‘Š