wchagas/pagseguro-react

Verificar se CreditCard se está montado

Opened this issue · 0 comments

Ao tentar gerar um pagamento ele estoura um erro. tem que verificar se o componente está montado.

componentDidMount() { 
  this._ismounted = true;
}

componentWillUnmount() {
   this._ismounted = false;
}

Provavelmente está acontecendo porque estou tratando a apresentação do componente DirectPayment, ocultando no "re-render" se o status estiver loading == true.

<CreditCard {...this.props} amount={amount} onSubmit={onSubmit} onError={onError} cards={paymentMethods.find(item => item.name == 'CREDIT_CARD').options} />

Warning: Can't perform a React state update on an unmounted component. This is a no-op, but it indicates a memory leak in your application. To fix, cancel all subscriptions and asynchronous tasks in the componentWillUnmount method.
in CreditCard (created by DirectPayment/Forms/Payment)
in div (created by Context.Consumer)
in StyledComponent (created by Col)
in Col (created by DirectPayment/Forms/Payment)
in div (created by Context.Consumer)
in StyledComponent (created by Row)
in Row (created by DirectPayment/Forms/Payment)
in div (created by DirectPayment/Forms/Payment)
in DirectPayment/Forms/Payment (created by DirectPayment)
in div (created by Context.Consumer)
in StyledComponent (created by styled.div)
in styled.div (created by DirectPayment)
in div (created by Context.Consumer)
in StyledComponent (created by styled.div)
in styled.div (created by DirectPayment)
in LoadLibrary (created by DirectPayment)
in DirectPayment (created by Checkout)