-
Notifications
You must be signed in to change notification settings - Fork 130
Fix/use eligible methods hook #819
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 5 commits
218dc79
74db902
7a46eda
81cbb7f
caf8b97
414fc1e
d7e8728
afd0097
5c0654c
808b819
9a1e29a
3a80b00
71d1aab
3d329a4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "@paypal/react-paypal-js": patch | ||
| --- | ||
|
|
||
| Integrate useEligibleMethods hook into PayLaterOneTimePaymentButton component to automatically fetch and dispatch eligibility to context. Also fixes React Strict Mode compatibility by resetting lastFetchRef on cleanup. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -133,13 +133,12 @@ export function useEligibleMethods( | |
| } | ||
| }) | ||
| .finally(() => { | ||
| if (isSubscribed) { | ||
| setIsFetching(false); | ||
| } | ||
| setIsFetching(false); | ||
| }); | ||
|
|
||
| return () => { | ||
| isSubscribed = false; | ||
| lastFetchRef.current = null; // Reset fetch tracking on unmount or dependency change | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Instead of setting
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good question. I think this fix was related to StrictMode double mounting practice.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi @nityasp This is to pass our StrictMode test in react, Consider this flow: I hope this illustration can clarify your confusion. Lmk if you have any other questions. Thank you!
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for explaining it in detail. I understood it. |
||
| }; | ||
| }, [ | ||
| sdkInstance, | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.