Skip to content

Commit

Permalink
Merge pull request #406 from reactioncommerce/ajporlante-fix-405-bill…
Browse files Browse the repository at this point in the history
…ing-not-same-as-shipping-address

fix: trigger onChange when new address is received
  • Loading branch information
kieckhafer authored Mar 5, 2019
2 parents 2fe1eca + ba386a0 commit 2624e04
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions package/src/components/AddressChoice/v1/AddressChoice.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React, { Component } from "react";
import PropTypes from "prop-types";
import isEqual from "lodash.isequal";
import { withComponents } from "@reactioncommerce/components-context";
import { addressToString, CustomPropTypes } from "../../../utils";

Expand Down Expand Up @@ -69,6 +70,13 @@ class AddressChoice extends Component {
this.state = { selectedOption };
}

componentDidUpdate({ addresses }) {
const { selectedOption } = this.state;
if (selectedOption === "0" && !isEqual(addresses[0], this.props.addresses[0])) {
this.handleChangeSelection(selectedOption);
}
}

handleChangeAddress = (address) => {
this.props.onChange(address);
}
Expand Down

0 comments on commit 2624e04

Please sign in to comment.