は、私はいくつかは、私が反応し、次のクラスがあり、その中のネイティブコードに反応持って呼ばれているレンダリング:コンストラクタは呼び出されませんが、
import React, { Component } from 'react';
import { ScrollView, StyleSheet, TouchableHighlight, View, Text, Platform } from 'react-native';
import { bindActionCreators } from 'redux'
import { connect } from 'react-redux';
export default class MyList extends Component {
constructor(props) {
super(props);
console.log("In constructor!");
//some other code
}
componentWillMount() {
console.log("In componentWillMount!");
}
render() {
console.log("In render method!");
return (
<ScrollView
horizontal={true}
showsHorizontalScrollIndicator={true}
onLayout={this._onScrollViewLayout}
onScroll={this._onScroll}
ref={SCROLLVIEW_REF}
scrollEventThrottle={8}
>
//some other code
</ScrollView>
);
}
}
問題はこれだけがログに印刷されていることである
:
ReactNativeJS: In render method!
constructor
またはcomponentWillMount
のいずれかのログが表示されないのはなぜですか?render
メソッドの前に呼び出す必要がありますか?
EDIT:
伐採のために、私はreact-native log-android
を使用しています。問題は、私はちょうどGoogleのChromeでコードをテストし、それがうまく動作しているようだreact-native log-android
であるかもしれないよう
'Constructor'と' componentWillMount'は1回だけ(コンポーネントがマウントされているとき)呼び出されます。その後、毎回コンポーネントを更新すると、これらのメソッドは呼び出されませんが、 'render'が呼び出されます。コンポーネントが実装されていてもこれらのメソッドが呼び出されないと言っていますか? –
しかし、これらのメソッドからのロギングは引き続き表示されるはずです。ロギングは、コンストラクタが呼び出されるときに範囲内にあるミドルウェアです。 – octavian