GithubHelp home page GithubHelp logo

Comments (10)

domlyons avatar domlyons commented on May 23, 2024 7

Hey, we've encountered the same problem on our project, as not all our users need stripe loaded. We created this library to asynchronously load scripts. The example on the page is essentially a StripeProviderProvider. This has more or less solved the problem for us. I think it has advantages over the other discussed methods because it is event driven and doesn't use polling. Let me know if you see any issues with this.

from react-stripe-elements.

rixth avatar rixth commented on May 23, 2024

Initial idea for a fix: #25

from react-stripe-elements.

michelle-stripe avatar michelle-stripe commented on May 23, 2024

@rixth thanks for the report and the PR! I went ahead and fleshed out some alternative ideas here: #25 (comment)

from react-stripe-elements.

michelle avatar michelle commented on May 23, 2024

@rixth Thinking on this a bit more, is there a reason y'all can't do the polling in your own code and only render the StripeProvider tree once window.Stripe is available? None of react-stripe-elements' components are useful until window.Stripe is available. After putting together the example in the custom elements instance PR (#27), it feels like a worse developer experience overall. The benefits of polling and then passing the elements instance compared to polling and then creating the StripeProvider-tree seem minimal. Perhaps we can improve the error messaging in StripeProvider and in the README and provide a cookbook for dealing async loading. What are your thoughts?

from react-stripe-elements.

rixth avatar rixth commented on May 23, 2024

So the main issue I see with this approach is the exactly one that you identified here: #25 (comment) In fact isn't #25 more-or-less what you're describing, but supported explicitly by the library?

We'd be blocking the display of everything inside the stripe provider until Stripe was available. In the case of passing the elements prop to the components themselves has the added benefit that we would be minimizing the amount of page content that is dependent on Stripe before displaying.

from react-stripe-elements.

michelle-stripe avatar michelle-stripe commented on May 23, 2024

from react-stripe-elements.

rixth avatar rixth commented on May 23, 2024

Going down to the individual fields is probably a bit much, but limiting to the form, would be fine. So what you're suggesting is essentially what #25 does, only hoisting this behaviour up and out in to the application? Just trying to get clarity before I spend time on this

from react-stripe-elements.

rixth avatar rixth commented on May 23, 2024

It seems like I'm essentially going to write a StripeProviderProvider :)

from react-stripe-elements.

michelle-stripe avatar michelle-stripe commented on May 23, 2024

from react-stripe-elements.

iMerica avatar iMerica commented on May 23, 2024

Thank you @domlyons. Very cool.

from react-stripe-elements.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.