We are working on responsive app that supports different layouts for mobiles and tablets and portrait/landscape orientations. On iPads we present gallery in a native navigation modal, which is not a full screen size, so we have to use onLayout callback of gallery container and containerDimensions property:
This results in incorrect behaviour when containerDimensions changes, for example when changing orientation. I looked around in source code and was able to fix it by simply adding dimensions.width to useEffect dependencies:
So it looks like it is just missing dependencies, but I was wondering why it specifically has eslint-disable-next-line react-hooks/exhaustive-deps rule which would have helped to avoid the issue in the first place.
We are working on responsive app that supports different layouts for mobiles and tablets and portrait/landscape orientations. On iPads we present gallery in a native navigation modal, which is not a full screen size, so we have to use
onLayout
callback of gallery container andcontainerDimensions
property:This results in incorrect behaviour when containerDimensions changes, for example when changing orientation. I looked around in source code and was able to fix it by simply adding
dimensions.width
to useEffect dependencies:So it looks like it is just missing dependencies, but I was wondering why it specifically has eslint-disable-next-line react-hooks/exhaustive-deps rule which would have helped to avoid the issue in the first place.