How to make ThreeJS respect the size of the container when resizing?

I have a canva already set with a proper width that is responsive. When the page loads, ThreeJS respects the size of the canva and then loads the model accordingly.

The problem is when I resize the page, the canva does not change its size, even if I try to use a function to set the renderer size. If I reload the page with this new “resized” window, the ThreeJS respects and then loads the model accordingly.

I followed this tutorial from ThreeJS docs.

What is wrong?

You’re threejs logic all looks correct. I think you might just have a problem with your CSS?