I\'m trying to measure a view using a ref
, but the width
returned is 0 despite the fact that I see the view displayed on the screen (and it\'s far
During the night some guys talked about a (hacky) solution but it solved my problem, found it here: https://github.com/facebook/react-native/issues/953
Basically the solution is to use setTimeout
and everything just works magically:
componentDidMount: function() {
setTimeout(this.measureProgressBar);
},
measureProgressBar: function() {
this.refs.progressBar.measure((a, b, width, height, px, py) =>
this.setState({ progressMaxSize: width })
);
}