React-native-web: ScrollView onContentSizeChange running without size change

Created on 13 Dec 2019  Â·  2Comments  Â·  Source: necolas/react-native-web

The problem
If I add onContentSizeChange prop to my scrollView, it is running every millisecond without size change

Here is my code

<ScrollView onContentSizeChange={(width, height) => {
        this.setState({scrollHeight: height});
        console.log(width)
}} 
style={{height:this.state.height, width:this.state.width}}>


                {/* Another Components */}


</ScrollView>

How to reproduce
Fix listener to work only on content size change

Environment

  • React Native for Web (version): 0.11.7
  • React (version): 16.12.0
  • Browser: Google Chrome v78.0.3904.108 (Mac OS)

Most helpful comment

I face the problem as well but it is happening in Safari 12.1.1. The prop is not triggered once the content's size is changing. Weirdly enough, the prop is working after you resize the browser.

The prop is working as expected on chrome 79.0.3945.88 and firefox 72.0.1.

weirdprops2

related sandbox: https://codesandbox.io/s/sticky-scroll-wun6s

A temporary solution to me by calling window.dispatchEvent(new Event(‘resize’)) in safari at the end of the action which triggers the content size changing.

All 2 comments

I face the problem as well but it is happening in Safari 12.1.1. The prop is not triggered once the content's size is changing. Weirdly enough, the prop is working after you resize the browser.

The prop is working as expected on chrome 79.0.3945.88 and firefox 72.0.1.

weirdprops2

related sandbox: https://codesandbox.io/s/sticky-scroll-wun6s

I face the problem as well but it is happening in Safari 12.1.1. The prop is not triggered once the content's size is changing. Weirdly enough, the prop is working after you resize the browser.

The prop is working as expected on chrome 79.0.3945.88 and firefox 72.0.1.

weirdprops2

related sandbox: https://codesandbox.io/s/sticky-scroll-wun6s

A temporary solution to me by calling window.dispatchEvent(new Event(‘resize’)) in safari at the end of the action which triggers the content size changing.

Was this page helpful?
0 / 5 - 0 ratings