score:1

Accepted answer
orderLinesRef = [];
getLines = () => {
    return this.state.orderLines.map((item, _) => (
      <OrderLine
        key={item.id}
        ref={ref => (this.orderLinesRef[_] = ref)}
        updateCallback={this.updateTotal}
        {...item}
      />
    ));
  };

score:0

getLines = () => {
return this.state.orderLines.map((item, _) =>
  <OrderLine 
  ref={instance => this.myOrder = instance}
    key={item.id} 
    updateCallback={this.updateTotal}
    {...item} 
  />)

score:0

  updateTotal = () => {
    // You'll need a way to get the product price and quantity for each order line
    let total = this.state.orderLines.reduce((sum, line) => {
      sum = sum + this.getTotal(line.product.price, line.quantity);
    }, 0);

    this.setState({ total });
  };

Related Query

More Query from same tag