use-event-listener icon indicating copy to clipboard operation
use-event-listener copied to clipboard

Saving handler in useEffect()

Open toschlog opened this issue 4 years ago • 1 comments

The current implementation contains this:

useEffect(() => {
    savedHandler.current = handler;
}, [handler]);

Is there any reason this has to be in a useEffect()? I would just do:

savedHandler.current = handler;

I would think that would be quicker to just store handler every time than having useEffect() check to see if it's changed.

Or am I missing something?

toschlog avatar Aug 18 '21 21:08 toschlog

+1 had to make extra API calls to get around this problem.

LeeMcNeil avatar Aug 22 '14 18:08 LeeMcNeil

I also had this problem. Ended up just updating through the customer API:

$result = Braintree_Customer::update('the_customer_id', array(
    'creditCard' => array(
        'paymentMethodNonce' => 'nonce-received-from-your-client',
        'options' => array(
            'updateExistingToken' => 'the_payment_method_token',
            'verifyCard' => true
        )
    )
));

mdluna77 avatar Nov 20 '14 01:11 mdluna77

Please excuse my slow response to the original issue.

This was a documentation issue after the original launch that we've since corrected. @mdluna77 is correct that in order to use a paymentMethodNonce to update an existing Braintree_PaymentMethod, one must pass in the updateExistingToken option with the existing token via a call to Braintree_Customer::update.

If you have any further issues with your integration don't hesitate to contact us either by email ([email protected]) or by phone (877.434.2894).

Best!

openbl avatar Nov 20 '14 22:11 openbl

Hello, I am dealing with this same issue. Could it have been broken again?

TylerScottSullivan avatar Mar 17 '17 23:03 TylerScottSullivan

@TylerScottSullivan, if you're having this issue, it is most likely something specific to your integration. Our technical support team is the best to help you work through this. Feel free to email ([email protected]) or call (877.434.2894).

openbl avatar Mar 17 '17 23:03 openbl

+1 work in sandbox with fake nonces but not with real nonces.

mairo744 avatar Nov 09 '22 11:11 mairo744

@mairo744 please reach out to our technical support team to figure out what is going wrong: https://developer.paypal.com/braintree/help

crookedneighbor avatar Nov 09 '22 15:11 crookedneighbor