react-paypal-js icon indicating copy to clipboard operation
react-paypal-js copied to clipboard

[BUG]: actions.disable() in onInit doesn't disable the button

Open shinchannn opened this issue 3 years ago • 2 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues.

🐞 Describe the Bug

Hi, I'm trying to validate the my form before entering PayPal flow. As far as I know, there's no code example out there about how to implement this in <PayPalButtons/>, so I referred to the documentation in this page. I tried to attach the prop onInit to my <PayPalButtons/> component. The function runs, as I can tell from the content it prints. However, the window pops up upon click like nothing was changed. So even my first step in validation can't be finished.

😕 Current Behavior

The window pops up even if actions.disable() is written in onInit.

🤔 Expected Behavior

I tried to call the actions.disable() in the environment using <script>, it won't respond to clicking.

🔬 Minimal Reproduction

Codesanbox here for reproduction. (https://codesandbox.io/s/oninit-issue-464e8b).

🌍 Environment

| Software         | Version(s) |
| ---------------- | ---------- |
| react-paypal-js  |            |
| Browser          |            |
| Operating System |            |

Relevant log output

No response

Code of Conduct

  • [X] I agree to follow this project's Code of Conduct

➕ Anything else?

No response

shinchannn avatar Jul 19 '22 03:07 shinchannn

hi @shinchannn, I am facing the same issue as well. Did you manage to find a solution or workaround for this?

AwaMelvine avatar Aug 02 '22 05:08 AwaMelvine

Hi @shinchannn and @AwaMelvine we provide a disabled prop for managing the disabled state in react-paypal-js. You should be able to use this instead of wiring up the behavior in onInit(). Ex:

Screen Shot 2022-08-02 at 10 09 58 AM

gregjopa avatar Aug 02 '22 15:08 gregjopa

This issue has been automatically marked as stale. If this issue is still affecting you, please leave any comment (for example, "bump"), and we'll keep it open. We are sorry that we haven't been able to prioritize it yet. If you have any new additional information, please include it with your comment!

github-actions[bot] avatar Sep 17 '22 02:09 github-actions[bot]

Closing this issue after a prolonged period of inactivity. If this issue is still present in the latest release, please create a new issue with up-to-date information. Thank you!

github-actions[bot] avatar Sep 22 '22 02:09 github-actions[bot]

bump

MatthewTang avatar Oct 03 '22 04:10 MatthewTang

Hi @shinchannn and @AwaMelvine we provide a disabled prop for managing the disabled state in react-paypal-js. You should be able to use this instead of wiring up the behavior in onInit(). Ex:

Screen Shot 2022-08-02 at 10 09 58 AM

This solution doesn't quite fit my use case, since I need to post my server and ensure a successful response after they click the paypal button but before letting the payapl popup appear.

Hope this make sense, Thanks!

MatthewTang avatar Oct 03 '22 05:10 MatthewTang

does this mean that this is no longer working with react?

onInit={async (data, actions) => {
  const ok = await canProceed();
  ok ? actions.enable() : actions.disable();
}}

AndrewEastwood avatar Dec 26 '22 19:12 AndrewEastwood