Reputation: 1383
I have the following line of codes.
constructor(props) {
super(props);
this.state = {
trends_1: [
{ start: [parseFloat(props.ab), parseFloat(props.cd)], end: [parseFloat(props.wy), parseFloat(props.yz)], appearance: { stroke: "green" }, type: "XLINE" }
]
};
}
How can I access the value of parseFloat(props.ab)
and parseFloat(props.yz)
?
Upvotes: 0
Views: 69
Reputation: 33974
You can access it with index position
this.state.trends_1[0].start[0]
this.state.trends_1[0].start[1]
this.state.trends_1[0].end[0]
this.state.trends_1[0].end[1]
Upvotes: 2
Reputation: 5912
You have to access like this.
let ab = this.state.trends_1[0].start[0];
let cd = this.state.trends_1[0].start[1];
Upvotes: 1