UseRef to trigger a styled tag

Does it make sense to useRef to trigger a styled tag which is loaded
in application via a custom librabry?

Would be a good practice to use querySelector instead of useRef? [Trying to overwrite the styling which comes from a custom library something similar to Material UI]

document.querySelector(StyleTagToChange).appendChild(document.createTextNode(newCSSRule)