1
ref
しか持っていない場合、反応ネイティブ要素の高さをどのように測定できますか?反応固有のref(ListView)の高さを測定
NativeMethodsMixinを参照してください。ただし、実装方法は不明です。
私はそれを含めて試してみた:
import { NativeMethodsMixin } from 'react-native';
class Foo extends Component {
mixins: [NativeMethodsMixin]
measure(ref) {
console.log(NativeMethodsMixin.measure(ref));
}
...
}
が、アプリはNativeMethodsMixin
が定義されていないと文句を言い。
私はRCTUIManager
ルートに行く場合:
import { NativeModules } from 'react-native';
const RCTUIManager = NativeModules.UIManager;
class Foo extends Component {
measure(ref) {
const height = RCTUIManager.measure(ref, (x, y, width, height, pageX, pageY) => height));
console.log(height);
}
...
}
を、私はエラーを取得する:Uncaught TypeError: Converting circular structure to JSON
は、私はちょうどそのref
の高さを取得したいです。私は何が欠けていますか?
はこれを見つけました。 https://facebook.github.io/react/docs/more-about-refs.html – chandlervdw