Comments (5)
@gregjopa thank you for all the pointers- awesome that you're thinking about user empathy and providing the best UX for buyers.
My team and I have been learning best SDK practices from react-paypal-js
and it's been very informative. For example, there isn't documentation on Buttons().close()
and we learned about it from the work that was done here. Also, personally I haven't made use of the reducer hooks API, and this project has been 💡💡💡 for me. Learned lots!
from react-paypal-js.
Hi @gregjopa! Thanks for creating this issue -it's very well thought out 🚀 I'm onboard with adding a prop to PayPalScriptProvider
. It can be optional.
Semantically, shouldLoadScript
doesn't tell me a lot in the context of PayPalScriptProvider
. I like your idea of calling the it lazyLoadScript
, skipLoadScript
, or even deferLoading
(defaults to false).
Re: kicking off the loading, are you thinking of supporting both of these? Either should work for us. (2) is nice since it abstracts away the logic from the client ✨
- Update the value passed into the
shouldLoadScript
prop and set it equal to true.- Wait for the the component (ex:
<PayPalButtons />
) to get rendered which would dispatch an action to kick off the script loading by changing the state to pending.
from react-paypal-js.
Here are some other naming ideas for this new prop for <PayPalScriptProvider>
:
lazyLoadScript
- defaults to false.skipLoadScript
- defaults to false.eagerlyLoadScript
- defaults to true.
from react-paypal-js.
I'm onboard with adding a prop to PayPalScriptProvider. It can be optional.
Thanks @avocadomayo! That's great to hear 🥳
Semantically, shouldLoadScript doesn't tell me a lot in the context of PayPalScriptProvider. I like your idea of calling the it lazyLoadScript, skipLoadScript, or even deferLoading (defaults to false).
Agreed. deferLoading
is a great suggestion! Let's go with that.
Re: kicking off the loading, are you thinking of supporting both of these? Either should work for us. (2) is nice since it abstracts away the logic from the client ✨
Yes I think we should support both.
Usage of deferLoading={false}
Another thing to mention is we recommend loading the JS SDK earlier in the user flow on a page preceding the checkout page in order to render the Buttons as fast as possible. So waiting to load the script until the button is shown to the buyer is not ideal. We should still support it but wanted to mention the performance concern. Here's a note from the paypal dev docs about it:
for a bonus performance boost, load the JavaScript SDK asynchronously on a page that precedes the checkout page. This approach pre-caches the script, making future loads and renders instantaneous
The good news is react-paypal-js already supports dispatching an action to load the script. So when using deferLoading=true
, we can put a note in the readme to encourage devs to dispatch an action to load the script later on in the user flow but before getting to the checkout page. Ex:
const [{ isNotStarted, options }, dispatch] = usePayPalScriptReducer();
// dispatch an action to start loading the script from a preceding page
if (isNotStarted) {
dispatch({
type: "setLoadingStatus",
value: SCRIPT_LOADING_STATE.PENDING,
});
}
I think the isNotStarted
derived prop is the only new thing needed to support the above snippet. Beside that, it should just work. It's cool that we can leverage this new deferLoading
prop along with the dispatcher to control script loading 🎉
from react-paypal-js.
@avocadomayo thanks for helping design this feature! It's included in the 5.2.0 release and it's documented here: https://github.com/paypal/react-paypal-js#deferloading.
Also, thanks for your kind words about this project 😄 💯
from react-paypal-js.
Related Issues (20)
- [BUG]: options inside `usePayPalScriptReducer` are still in kebab-case format" HOT 3
- [BUG]: PayPalHostedFieldsProvider does not support vault token creation HOT 4
- [BUG]: npm installs 0.0.1-security security holding package HOT 7
- [BUG]: Advanced Checkout React Integration fails to render with successful token from generateClientToken; throws Braintree Integration error HOT 2
- [FEATURE]: Ability to change the focus indicator style HOT 2
- [BUG]: PayPalScriptProvider does not accept @dataClientToken param; throws BraintreeError: Authorization is invalid. HOT 2
- [FEATURE]: Disable shipping form HOT 4
- [FEATURE]: how do i set a free 7-day trial? HOT 2
- [BUG]: popup_open_error_iframe_fallback HOT 1
- [BUG]: Permission Denied Error when Accessing Order Details with facilitatorAccessToken HOT 4
- [BUG]: AED Currency not working while integrating with braintree HOT 6
- [BUG]: crossorigin attribute is not supported HOT 5
- [BUG]: Syntax errors in paypal/react-paypal-js/dist/types/types/scriptProviderTypes.d.ts HOT 1
- [BUG]: Sometimes buttons are not displayed HOT 1
- [BUG]: Failed to render <PayPalHostedFieldsProvider /> component. HOT 1
- [BUG]: Paypal buttons not rendering HOT 2
- [BUG]: In development, there is a button on my page that can be triggered HOT 4
- [BUG]: Clicking on credit card payment has a probability of triggering PayPal's payment pop-up window
- [BUG]: Sometimes paypal subscription details along with total not showing.
- [BUG]: Issue with Sandbox Account Payment Failure
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-paypal-js.