チャイルドがマウントされているかどうかを検出する方法はありますか? Isotope を初期化するとき、初期化のためにすべての子コンポーネントをマウントする必要があります。5 ミリ秒のタイムアウトで期待どおりに動作していますが、もっと良い方法があると確信しています。
componentDidMount: function() {
var container = this.refs.vinesOverview.getDOMNode();
setTimeout(function() {
var isotope = new Isotope(container, {
itemSelector: ".vine_item",
layoutMode: "masonry",
resizable: true,
gutter: 0,
isFitWidth: true
});
this.setState({ isotope: isotope });
}.bind(this), 5);
}
アップデート
私は今これを試しました:
componentDidMount: function() {
var container = this.refs.vinesOverview.getDOMNode();
console.log(container.offsetHeight); // console output 0
setTimeout(function() {
console.log(container.offsetHeight); // console output 3150
}, 5);
},
5ms後に高さを計算しましたか?それがアイソトープが機能しない理由です。それはバグですか、それとも正常ですか?ありがとう!