1
0
mirror of https://github.com/aclindsa/moneygo.git synced 2024-12-26 23:42:29 -05:00

AmountInput: Actually initialize state

This has been broken since the switch to ES6 classes
This commit is contained in:
Aaron Lindsay 2017-06-11 06:44:59 -04:00
parent a4b99381d3
commit d03eef3035

View File

@ -117,7 +117,8 @@ class AmountInput extends React.Component {
if (!props) if (!props)
return { return {
LastGoodAmount: "0", LastGoodAmount: "0",
Amount: "0" Amount: "0",
initialized: false
} }
// Ensure we can edit this without screwing up other copies of it // Ensure we can edit this without screwing up other copies of it
@ -129,7 +130,8 @@ class AmountInput extends React.Component {
return { return {
LastGoodAmount: a, LastGoodAmount: a,
Amount: a Amount: a,
initialized: true
}; };
} }
constructor() { constructor() {
@ -138,7 +140,8 @@ class AmountInput extends React.Component {
this.state = this.getInitialState(); this.state = this.getInitialState();
} }
componentWillReceiveProps(nextProps) { componentWillReceiveProps(nextProps) {
if ((!nextProps.value.eq(this.props.value) && if (!this.state.initialized ||
(!nextProps.value.eq(this.props.value) &&
!nextProps.value.eq(this.getValue())) || !nextProps.value.eq(this.getValue())) ||
nextProps.security !== this.props.security) { nextProps.security !== this.props.security) {
this.setState(this.getInitialState(nextProps)); this.setState(this.getInitialState(nextProps));