I havent understood the first image exactly, so my answer might not be that useful, but still sharing few points which might help you out. For the below points I am assuming you are building a plugin. (I didnt understood what you meant by “third-party libraries”)
First of all, we are not supposed to put any kind of styling within the react code. That is all the styling, the CSS should go inside a new file called styles.css, which should be also present within your plugin folder. But, in rare cases where the styling is changing dynamically and you cannot do it using class toggling, in that case you may hardcode the CSS. But that too, I feel is very rare case as almost everything is possible through CSS class names toggling.
Second thing, I have too faced this issue in the past. For example, I was using the reactFlow package. And when I imported it, I didnt saw anything. Turn out, I had to set the width and height of the reactFlow component to a absolute value, then only it appear within the parent div properly. You have given the height as 300px which looks correct, try the same for width as well and check if the parent of this containerRef is properly wrapping the div. You can debug this through the Developer console window.