79750718

Date: 2025-08-29 19:40:52
Score: 0.5
Natty:
Report link

What you are trynna do is when you drag the container on the right it will get wider and the .aside will get narrower. However you gave .aside a fix width value of 500px which stops it from shrinking.

You need to change your stylesheet of .aside into:

.aside {
background: #aaa;
height: 100%;
min-width: 320px;
flex-grow: 1;
}

So that the flex layout can shrink its width to give the container space to grow

Meanwhile you passed an empty array into dependency of useLayoutEffect hook which will only execute once before the browser paints the screen when the container.current is null

add dependency to the useLayoutEffect:

useLayoutEffect(() => {...}, [container.current]); 

this way it will execute when the container ref is bound with the element

Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Starts with a question (0.5): What you are
  • Low reputation (1):
Posted by: musketeerdt