In React you don't usually access the DOM directly, you let React do that for you. Using React refs is a way to do it. You do not need to assign ids this way or use other query selectors.
This answer goes into details: https://stackoverflow.com/a/69260293/13637489