I'm sure the store updates (I'm using redux), 'cause I can get the updated value in componentWillReceiveProps, but in my dynamically created components the props won't update (mainting the value of props when the component was being created).
How I create the components:
_getFetchDataDevice(...) {
[...]
coordinatesObjectsAR.forEach((tempObject, i) => {
objectsComponenets.push(
<ViroFlexView width={10} key={"viro_flex_"+i} transformBehaviors={["billboard"]} scale={[0.7*(distanceFromObjectsAR[i]/60),0.68*(distanceFromObjectsAR[i]/60),0.9*(distanceFromObjectsAR[i]/60)]} position={[coordinatesObjectsAR[i].x,0,coordinatesObjectsAR[i].z]} height={16} backgroundColor={'pink'} style={{ flexDirection: 'column' }} >
<ViroFlexView key={"viro_flex_inside_"+i} backgroundColor={'white'} style={{ flex: 1, flexDirection: 'column' }} >
<ViroText
key={"distance_"+i}
backgroundColor={'pink'}
style={{ flex: 1, color: 'purple', marginLeft:.2 }}
text={ this.props.distanceBetweenUserLocationAndPoints[i].toFixed(2).toString() + "m\n"}
fontSize={162} />
<ViroText
key={"xy_"+i}
backgroundColor={'pink'}
style={{ flex: 1, color: 'purple', marginLeft:.2 }}
text={"x:"+coordinatesObjectsAR[i].x.toFixed(2).toString()+",y:"+coordinatesObjectsAR[i].z.toFixed(2).toString()}
fontSize={162} />
<ViroText
key={"title_"+i}
backgroundColor={'pink'}
style={{ flex: 1, color: 'purple', marginLeft:.2 }}
text={jsonObjects[i].title}
fontSize={162} />
<ViroImage onClick={() => {this._startNavigationToLocal(i)}}
height={8}
width={6.75}
key={"button_"+i}
source={require("../resource/image/navigation.png")}
/>
</ViroFlexView>
</ViroFlexView>
);
});
this.setState({objects: objectsComponenets});
[...]
}
The props I need to get the updated value is this.props.distanceBetweenUserLocationAndPoints.
The render of the dynamically created components stored inside the state objects is:
return (
<ViroARScene onTrackingUpdated={this._onTrackingUpdated} onAnchorFound={this._foundAnchor}>
<ViroText text={"Compass: "+compassDegree} transformBehaviors={["billboard"]} scale={[.5, .5, .5]} position={[0,0,-1]} style={styles.helloWorldTextStyle} />
{this.state.objects}
<ViroBox position={[0,0,-1]} scale={[.3, .3, .1]}/>
<ViroAmbientLight color={"#aaaaaa"} influenceBitMask={1} />
</ViroARScene>
);
The _getFetchDataDevice(...) is called inside a lifecycle method.
The this.state.objects works and renders the corrects Views I intended to, but when the this.props.distanceBetweenUserLocationAndPoints updates, the reference of it inside the dynamically created components don't update. Already tried to pass the props to local state, didn't work either.