OnLayout not starting in WebView

I try to use onLayouton mine WebView, but it does not start.

export default class Sandbox extends Component {
  render() {
    return (
      <View style={styles.fill}>
        <WebView
          onLayout={(event) => {
            console.log(event.nativeEvent.layout)
          }}
          source={{uri: 'https://github.com/facebook/react-native'}}
        />
      </View>
    )
  }
}

const styles = StyleSheet.create({
  fill: {
    flex: 1,
  },
})

Does anyone have an idea why this is not working? I checked the documentation and seemed to be available for use.

+8
source share
1 answer

If you want to get WebView dimensions, you can use onLayoutin the container view. Otherwise, if you need to get the dimensions of the HTML content, you can take a look at this post or use it onContentSizeChangeon Android.

0
source

Source: https://habr.com/ru/post/1664593/


All Articles