У меня небольшая проблема с запуском события поворота в реагирующем.
Я получаю сообщение об ошибке this.setState
undefined
. Когда я использую this.onLayout.bind(this)
, все равно ничего не происходит.
EDITED
App
const win = Dimensions.get('window');
constructor(props) {
super(props);
this.state = {
height: win.height,
width: win.width
}
}
onLayout (e) {
console.log(e);
this.setState({
height: e.nativeEvent.layout.height,
width: e.nativeEvent.layout.width,
})
}
render() {
return <View style={[styles.container, {width: this.state.width, height: this.state.height }]} onLayout={this.onLayout}>
<WebView
source={webapp2}
originWhitelist={'["*"]'}
automaticallyAdjustContentInsets={true}
allowFileAccess={true}
javaScriptEnabled={true}
domStorageEnabled={true}
scalesPageToFit={true}
scrollEnabled={false}
mixedContentMode='always'
/>
</View>
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
}
});
index.html (webapp)
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=0" />
<style media="screen" type="text/css">
#container, #test {
width:100%;
height:100%;
top:0;
left:0;
right:0;
bottom:0;
position:absolute;
user-select: none;
-webkit-user-select: none;
border:1px solid red;
}
</style>
</head>
<body>
<br><br><br><br><br><h1>aaaa</h1>
<div id="test"></div>
</body>
</html>
Также событие не вызывается, когда я использую простые <Text>