diff --git a/lib/three-d-secure-action.jsx b/lib/three-d-secure-action.jsx index f9a8d06..37bfc40 100644 --- a/lib/three-d-secure-action.jsx +++ b/lib/three-d-secure-action.jsx @@ -73,6 +73,7 @@ export default class ThreeDSecureAction extends React.PureComponent { const { actionTokenId } = props; + this._attached = false; this._container = React.createRef(); this._risk = this.context.recurly.Risk(); this._threeDSecure = this._risk.ThreeDSecure({ actionTokenId }); @@ -82,7 +83,9 @@ export default class ThreeDSecureAction extends React.PureComponent { } componentDidMount () { + if (this._attached) return; this._threeDSecure.attach(this._container.current); + this._attached = true; } render () { diff --git a/test/three-d-secure-action.test.jsx b/test/three-d-secure-action.test.jsx index 60d8ee1..2088c95 100644 --- a/test/three-d-secure-action.test.jsx +++ b/test/three-d-secure-action.test.jsx @@ -58,19 +58,9 @@ describe('', function () { /> )); - getThreeDSecureInstanceFrom(fixture).emit('ready', ); + getThreeDSecureInstanceFrom(fixture).emit('ready'); expect(subject).toHaveBeenCalled(); }); - - it('does nothing when no handler is provided', function () { - let fixture; - - render(withRecurlyProvider( - fixture = ref} /> - )); - - expect(() => getThreeDSecureInstanceFrom(fixture).emit('ready', example)).not.toThrow(); - }); }); describe('[onToken]', function () {