From 98a70529e86568be12998e22b29c31dd531f3a30 Mon Sep 17 00:00:00 2001 From: fernandomg Date: Thu, 2 Nov 2017 13:09:44 -0300 Subject: [PATCH] Moved pristine flag as part of the Component's state --- src/components/invest/index.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/components/invest/index.js b/src/components/invest/index.js index 687d0ffa4..903e594c5 100644 --- a/src/components/invest/index.js +++ b/src/components/invest/index.js @@ -11,13 +11,13 @@ import { defaultState, GAS_PRICE } from '../../utils/constants' export class Invest extends React.Component { constructor(props) { super(props); - this.pristineTokenInput = true; window.scrollTo(0, 0); if (this.tokensToInvestOnChange.bind) this.tokensToInvestOnChange = this.tokensToInvestOnChange.bind(this); if (this.investToTokens.bind) this.investToTokens = this.investToTokens.bind(this); var state = defaultState; state.seconds = 0; state.loading = true; + state.pristineTokenInput = true; this.state = state; } @@ -115,7 +115,7 @@ export class Invest extends React.Component { event.preventDefault(); if (!this.isValidToken(this.state.tokensToInvest)) { - this.pristineTokenInput = false; + this.setState({ pristineTokenInput: false }); return; } @@ -231,7 +231,7 @@ export class Invest extends React.Component { } tokensToInvestOnChange(event) { - this.pristineTokenInput = false; + this.setState({ pristineTokenInput: false }); let state = this.state; state["tokensToInvest"] = event.target.value; @@ -296,7 +296,7 @@ export class Invest extends React.Component { const totalSupply = (this.state.contractType === this.state.contractTypes.whitelistwithcap)?tierCap:standardCrowdsaleSupply; let invalidTokenDescription = null; - if (!this.pristineTokenInput && !this.isValidToken(this.state.tokensToInvest)) { + if (!this.state.pristineTokenInput && !this.isValidToken(this.state.tokensToInvest)) { invalidTokenDescription =

Number of tokens to buy should be positive

; }