examunity / bootstrap-rn

Bootstrap components for React Native
MIT License
2 stars 0 forks source link

Event listener of `Dimensions` api returns incorrect width #38

Closed markusjwetzel closed 1 year ago

markusjwetzel commented 1 year ago

We use the Dimensions api to determine the viewport in useViewport. However, on resize of a browser window the handler for the event listener provides an incorrect width.

When resizing the browser window to a smaller width, temporarily a width is provided that is smaller than the current resized window. Right afterwards the handler seems to be called a second time with the correct width.

If the smaller and larger breakpoint provide different views, this leads to a flickering, because temporarily the wrong viewport is used based on the incorrect width.

This behaviour has been seen on Chrome 117 and react-native-web ~0.18.10.